-
Notifications
You must be signed in to change notification settings - Fork 57
Conversation
And any other layouts in which ctrl/alt/meta modify the keyCode. Basically, event.which appears to be the reliable identifier. Gist: - If event.which is valid ASCII, and the keyIdentifier is something mappable (hex values good, left/right/enter bad), use event.which - If the keyIdentifier was not mappable, use the existing charCodeFromHexCharCode => keyFromCharCode mapping - Otherwise, use the keyIdentifier as-is.
@@ -20,10 +20,12 @@ exports.normalizeKeystrokes = (keystrokes) -> | |||
|
|||
exports.keystrokeForKeyboardEvent = (event) -> | |||
unless KeyboardEventModifiers.has(event.keyIdentifier) | |||
if event.keyIdentifier.indexOf('U+') is 0 | |||
keyIsAscii = event.keyIdentifier.indexOf('U+') is 0 | |||
if isAscii(event.which) and keyIsAscii |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this line is a bit confusing, with the local variable named keyIsAscii
and a function called isAscii
. Is it necessarily the case that a keyIdentifier beginning with U+
is always an ASCII character?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea for the variable: keyIdentifierIsHexCharCode
. It's long but it's also explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks, i'll add that change. I was aiming to catch cases like keyIdentifier: 'Right'
, and in that case keyIdentifierIsHexCharCode
is more accurate.
This is looking really good. Just tried it out locally and it's working for the Dvorak-Qwerty layout. One question remaining in my mind is whether we should be using |
Ah, that's what I get for using jQuery too much. (
Going to assume that means keyCode.. In any case, keyCode seems to do equally well in handling the Dvorak-Qwerty layout, so no reason not to make the switch. |
I assumed it was a typo as well. The entire Atom codebase is slowly recovering from an addiction to jQuery. |
Not sure what broke the build but I'm getting the same error on master, so I'm just going to leave this alone for now. Some issue in the "Downloading latest Atom release" step apparently |
Looks like a minor glitch in downloading Atom Shell. I restarted it and it's 🍏. |
Fix for dvorak-qwerty keyboard layout.
🎉 This fixes atom/atom#1659, right? |
It does, yes! As well as: #12 |
Hi @donmccurdy. So unfortunately basing everything off the keyCode caused a lot of regressions on international keyboard layouts. I think we're going to need to go with a table-based approach. To start with, it would be great to base behavior on a flag like |
It's too bad this wasn't as simple as it seemed, yes. Sorry for the trouble, but yeah reverting sounds reasonable if you're having to choose between the Dvorak niche and all the world's non-English speakers. :) I'm nervous about trying to auto-detect the OS-specific settings – not sure how much OS X exposes, but generally I'd hope that layout is opaque to applications, and anyway that might break once Chromium has reliable Could this be done as a standalone plugin? That would at least let us keep the keyIdentifier -> keyIdentifier table out of your main key-map module. There might actually be some interest from Windows and Linux Dvorak users there, too, so no point in limiting it to OSX. Chromium sounds like the harder option to me, but also more elegant (since none of this would be a problem if |
We could do it as a package, but where would you want to intercept events? Seems like having some sort of API for assigning a translation table could be a useful primitive in that situation. |
Not quite sure. I guess the question is what should be translated to what: Do we map keyIdentifiers to keyIdentifiers, or KeyboardEvents to KeyboardEvents? Probably any intercept should be beneath KeymapManager's |
That sounds reasonable, some kind of hook that can be added to normalize. |
It looks like this issue has been closed. When will the fix be released? |
It was released in May, but then reverted – relying |
That'd be great. |
Here you are! You are welcome! |
...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:
event.which
the keyIdentifier was not mappableevent.which was invalid but keyIdentifier was hex-ey, use the existing charCodeFromHexCharCode => keyFromCharCode mappingOther notes:
keydownEvent
, I'm overriding the defaultevent.which
to undefined, which would otherwise be 0 due to a bug in Webkit. 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 defaultevent.which
is not 0, on the off chance Webkit fixes this.event.which
through thekeyFromCharCode
function, but SO seems to think this is fine [1] [2] [3].