You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EmscriptenKeyboardEvent have different behaviour in Firefox/IE/Chrome #2817
When registering keyboard callback with HTML5 API i have different behaviour in Firefox Chrome and IE. I register with emscripten_set_keypress_callback, emscripten_set_keydown_callback and emscripten_set_keyup_callback to the same callback. I print the EmscriptenKeyboardEvent structure and i have different value in different browser.
Here is the complete structure "printf" for each browser for keypress/keydown/keyup:
You can note that key attribute is not the same, sometime empty, space or "Spacebar" string. In the documentation key attribute is recommanded and which is deprecated but which is the only attribute which is everywhere the same.
The unfortunate part here is that it looks like the new standard key does not seem to be implemented in new browsers either, which seems to leave a mess to the developer to research what is the best scheme to capture keyevents.
The idea of the Emscripten HTML5 API here is to provide the event structure as-is, untranslated, so I think there is no bug in this API that could be fixed - but perhaps there is a bug in our documentation that does not offer a solution to the developer to do the right thing.
If using which solves all your problems, then by all means, I recommend ignoring the deprecation comment in the docs, since I don't think any browsers will be able to ever kill off that field, and it will continue working for the end of time. What do you think?
I pushed a change to clarify the wording there. Perhaps that can help developers to avoid confusions. Let me know if that wording does not capture the situation properly.
Activity
juj commentedon Sep 24, 2014
The reason why I wrote that
whichis deprecated andkeyis recommended came directly from this MDN page: https://developer.mozilla.org/en-US/docs/Web/Events/keypress .The reason why
whichis not recommended is that it predates standardization, e.g. mentioned in this page: https://developer.mozilla.org/en-US/docs/Web/API/event.which .The unfortunate part here is that it looks like the new standard
keydoes not seem to be implemented in new browsers either, which seems to leave a mess to the developer to research what is the best scheme to capture keyevents.The idea of the Emscripten HTML5 API here is to provide the event structure as-is, untranslated, so I think there is no bug in this API that could be fixed - but perhaps there is a bug in our documentation that does not offer a solution to the developer to do the right thing.
If using
whichsolves all your problems, then by all means, I recommend ignoring the deprecation comment in the docs, since I don't think any browsers will be able to ever kill off that field, and it will continue working for the end of time. What do you think?julianlalu commentedon Sep 24, 2014
I think for the moment it's a good practice to stay with
which. For compatility with browsers until they implement the same stuff inkey, and i can stay a good pratice after to keep compatility with older version of browsers.I will just compare it to the keyCode hexa found here:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode
It's generally the same value in
which.The Emscripten documentation lost me of how capture key events.
Apply comment to HTML5 key event 'which' field to help developers not…
juj commentedon Sep 24, 2014
I pushed a change to clarify the wording there. Perhaps that can help developers to avoid confusions. Let me know if that wording does not capture the situation properly.