It'd be great if I could have the same javascript run in both the browser and node-webkit without any errors. But I'd also like to add features that are specific to either platform, like a "hit Esc to exit" in the node-webkit version, but not in the browser version. Is there some sort of conditional I can test to see if I am in node-webkit?
You could check
navigator.userAgent
or write your code in a way that you're first checking the features you want to use and fall back to another solution, which is the recommended way in most cases. Because what if some feature gets implemented in an update? You want to go back and change your code every time any browser updates?