atom/atom-keymap — pull request #22 by donmccurdy (2014-05-18 04:06:19+00:00)
Title: Fix for dvorak-qwerty keyboard layout.

...and any other layouts in which ctrl/alt/meta modify the keycode. Basically, `event.which` appears to be the more reliable identifier. Added a test case to catch any regression.

Gist:
- If event.which is valid ASCII, and the keyIdentifier is something mappable (hex values are, left/right/enter aren't), use `event.which`
- If the keyIdentifier was not mappable, use the existing charCodeFromHexCharCode => keyFromCharCode mapping
- Otherwise, use the keyIdentifier as-is.

Other notes:
- in `keydownEvent`, I'm overriding the default `event.which` to undefined, which would otherwise be 0 due to a [bug in Webkit](https://bugs.webkit.org/show_bug.cgi?id=16735). 0 is a valid keyCode, which is bad, and this seemed more reasonable than adding keycodes to all of your test cases. The override is skipped if the default `event.which` is *not* 0, on the off chance Webkit fixes this.

- I'm a little nervous about passing `event.which` through the `keyFromCharCode` function, but SO seems to think this is fine \[[1](http://stackoverflow.com/questions/9140388/keycode-and-fromcharcode-in-javascript)\] \[[2](http://stackoverflow.com/questions/10744793/javascript-event-which-and-charcodeat-working-together)\] \[[3](http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion)\].