georgemandis / konami-js

Adding the Konami Code easter egg to your projects since 2009! Compatible with gestures on smartphones and tablets as well. Compatible with all front-end frameworks and vanilla JavaScript
http://konamijs.mand.is/
MIT License
959 stars 122 forks source link

Future proof with new key event properties, remove deprecated ones #21

Closed georgemandis closed 3 years ago

georgemandis commented 8 years ago

See this comment from pull request #20:

https://github.com/snaptortoise/konami-js/pull/20#issuecomment-141828647

Short summary: we shouldn't use these (theoretically)

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which

We should be using these:

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key

In reality there doesn't seem to be browser consensus with the new ones and the old ones work fine.

So... leaving this open for a future fix.

georgemandis commented 6 years ago

Belated update: If/when the major rewrite happens, Konami-JS should probably use key if for no other reason than it will play nicely with physical keyboard plugged into iOS per #27. Using code in iOS returns Unidentified for arrow-key presses as of iOS 11.2.

DavideCarvalho commented 5 years ago

Looks like IE11 and Edge doesn't have support for KeyboardEvent.key and KeyboardEvent.code yet https://caniuse.com/#feat=keyboardevent-key https://caniuse.com/#feat=keyboardevent-key But looks like there's a polyfill for that. If you plan on keeping supporting older browsers (Edge is not old, but microsoft isn't helping), warn about it in the docs or stay with legacy implementation https://stackoverflow.com/a/49903087