EmscriptenKeyboardEvent have different behaviour in Firefox/IE/Chrome · Issue #2817 · emscripten-core/emscripten (original) (raw)

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:

Chrome (v 37.0.2062.120) spacebar key:

eventType: 2, key: "", code: "", location: 0, repeat: 0, locale: "", char: "", charCode: 0, keyCode: 32, which: 32
eventType: 1, key: "", code: "", location: 0, repeat: 0, locale: "", char: "", charCode: 32, keyCode: 32, which: 32
eventType: 3, key: "", code: "", location: 0, repeat: 0, locale: "", char: "", charCode: 0, keyCode: 32, which: 32

Internet Explorer (v 11.0.9600.17280) spacebar key:

eventType: 2, key: "Spacebar", code: "", location: 0, repeat: 0, locale: "fr-FR", char: " ", charCode: 0, keyCode: 32, which: 32
eventType: 1, key: "Spacebar", code: "", location: 0, repeat: 0, locale: "fr-FR", char: " ", charCode: 32, keyCode: 32, which: 32
eventType: 3, key: "Spacebar", code: "", location: 0, repeat: 0, locale: "fr-FR", char: " ", charCode: 0, keyCode: 32, which: 32

Firefox (v 32.0.2) spacebar key:

eventType: 2, key: " ", code: "", location: 0, repeat: 0, locale: "", char: "", charCode: 0, keyCode: 32, which: 32
eventType: 1, key: " ", code: "", location: 0, repeat: 0, locale: "", char: "", charCode: 32, keyCode: 0, which: 32
eventType: 3, key: " ", code: "", location: 0, repeat: 0, locale: "", char: "", charCode: 0, keyCode: 32, which: 32

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.