Background
Keyboard events introduce new properties, .key and .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.log the 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.
document.addEventListener('keydown', function (e) {
console.log('W3:', e.type, e.code, e.key, e.keyCode);
});
$(document).on('keydown', function (e) {
console.log('jQuery:', e.type, e.code, e.key, e.keyCode);
});
Results
jQuery: keydown undefined ArrowRight 39
W3: keydown ArrowRight ArrowRight 39
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.
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.