Expose KeyboardEvent.code on jQuery event #3978
Comments
|
Agreed and I am thinking this is a typo because we have The problem with trying to normalize the names in IE11 is that it is especially bloating to put a comprehensive mapping like that in jQuery. If every person who ever used jQuery needed it that might make sense, but very few people need more than one or two keys. I should also mention that you can get this property in |
|
I don't think jQuery ever supported it by default. If it is a standard property then we should add it to the list. |
|
I appreciate the feedback. I understand the bloat argument and I can use regex to make the ‘Arrow’ bit optional or use multiple case statements to satisfy both implementations, but it's slightly odd for an abstraction library to not abstract away such differences. Hopefully M$ will prioritize standards compliance -- but I’ve lost that bet before... Step 1 is just getting .code back into the event object.
Cheers
… On Feb 14, 2018, at 5:13 AM, Dave Methvin ***@***.***> wrote:
Agreed and I am thinking this is a typo because [we have char and key[(https://github.com/jquery/jquery/blob/4a2bcc27f9c3ee24b3effac0fbe1285d1ee23cc5/src/event.js#L618-L620) but not code. I don't even see a char listed anywhere in the specs? @jbedard <https://github.com/jbedard> do you know? It's been around since jQuery 1.7 so it's not recent. I know the specs have changed several times over the years (which, keyCode/charCode, key/char).
The problem with trying to normalize the names in IE11 is that it is especially bloating to put a comprehensive mapping like that in jQuery. If every person who ever used jQuery needed it that might make sense, but very few people need more than one or two keys.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#3978 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AMD_nt019MkcZ8oUSVFZR88xpK6T92vdks5tUtvcgaJpZM4SFBx7>.
|
Background
Keyboard events introduce new properties,
.keyand.code. The latter being especially useful because it normalizes keyboard layouts (eg. Dvorak) and different locales.https://www.w3.org/TR/uievents-key/
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
https://developers.google.com/web/updates/2016/04/keyboardevent-keys-codes
Description
If you register a keydown event listener using W3 addEventListener and then
console.logthe event, the code property is present. If, however, you do the same thing using jQuery the code property is absent (presumably removed) -- but the key property is curiously present.Results
Link to test case
see: https://jsfiddle.net/waffledonkey/vwgu2u12/
While you're in there, IE implemented an older spec so they use 'Left', 'Right', 'Up' and 'Down' versus 'ArrowLeft', 'ArrowRight', 'ArrowUp' and 'ArrowDown' -- there may be other differences... If you still consider yourself an abstraction library I would LOVE if you could help pull IE up the hill.
The text was updated successfully, but these errors were encountered: