Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some missing keys to getEventKey #2192

Closed
wants to merge 2 commits into from

Conversation

Daniel15
Copy link
Member

getEventKey was missing a few keys that are correctly handled by Firefox's implementation of the DOM3 keyboard events.

References:
Firefox key list: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key
Key codes: http://www.aspdotnet-suresh.com/2013/09/character-keycodes-javascript-keyboard-keycodes.html

@zpao
Copy link
Member

zpao commented Sep 15, 2014

What's the cross-browser support story here? cc @syranide

@syranide
Copy link
Contributor

@zpao Uncertain. IIRC Meta cannot always be detected and it conflicts with some other keys on PC, but again I'm not 100% (related? #607 (comment)). I think I left out F13-F19 simply because it's not on standard keyboards and I couldn't verify that they actually worked as expected/conflicts (it goes up to F24 even IIRC).

If someone can verify the key codes with a physical keyboard AND verify that there are no conflicts (I only have access to PC at current) then I don't see why not.

@Daniel15
Copy link
Member Author

Good point, I'll have to test on a Windows PC. I've got an old laptop at home somewhere, I'll try to test it out. I was using a Mac while writing this code.

I have one of the Apple USB keyboards which is the only keyboard I've ever seen F13-F19 on, and they seemed to work. The key codes I used for F13-F19 correspond to the key codes listed in Mozilla's documentation (see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode)

@Daniel15
Copy link
Member Author

F20 through F24 are listed in Mozilla's documentation (key code 131 through 135) so I could add those too, I just have no way to test them on an actual keyboard.

@syranide
Copy link
Contributor

@Daniel15 Just checked, 91 maps to Windows Key and 93 maps to Context Menu on PC (which is what's vjeux reported at #607 (comment) and why those keys were removed).

F13-F24 is probably sound, my previous experience with Win32 APIs doesn't suggest that they can/have been repurposed for alternative uses http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

@Daniel15
Copy link
Member Author

Okay, so in that case I think 91 should actually map to Super (which is Windows Key or Command depending on environment) and me mapping it to Meta was a mistake. https://en.wikipedia.org/wiki/Super_key_(keyboard_button)

Should we just leave 93 out or should it be Meta? O.o

Also what is the keyboard code for the right Windows key in Windows? That should be Super too if possible.

This reminds me of keyboard handling in IE 5. You'd think things would have gotten better by now :(

@syranide
Copy link
Contributor

@Daniel15 From what I understand Super is not a generic name for the Window/Meta/whatever-key, but a predecessor-of-sorts to them. Additionally W3 explicitly states that it represents the The Super key..

My understanding is that 91/93 are OS/platform-specific. I imagine we could technically use navigator.platform to differentiate, but that it would be fragile and those keys have little-to-no practical use so I don't think there's a justification for the added complexity/fragility.

@Daniel15
Copy link
Member Author

Daniel15 commented Oct 1, 2014

Linux calls it the Super key and it seems fairly consistent. I've changed my diff to include F20 through F24 and 91 as "Super".

@syranide
Copy link
Contributor

syranide commented Oct 1, 2014

I'm very confident Super is distinct from OS.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.key

http://www.w3.org/TR/2014/WD-DOM-Level-3-Events-20140925/#keys-unicode
Lists keyModifierStateSuper and keyModifierStateOS.

Also, the url below has mapped Super to values 0x73 + 0x74 which is inconsistent with 0x5B + 0x5C as set by the Win32 API.
http://opensource.apple.com/source/WebKit/WebKit-7534.57.7/chromium/src/gtk/WebInputEventFactory.cpp
http://www.kbdedit.com/manual/low_level_vk_list.html

@sophiebits
Copy link
Collaborator

@Daniel15 @syranide What's the story here?

@Daniel15
Copy link
Member Author

I haven't had time to revisit this so I'm just going to close the pull request. Feel free to repurpose my changes.

These events seem extremely inconsistent across browsers at the moment which severely limits their use in real apps.

@Daniel15 Daniel15 closed this Feb 26, 2015
@syranide
Copy link
Contributor

@spicyj F13-F24 seems safe as far as I could tell. But I stand by interpretation that Super is a unique key and not a generic name for the OS-key.