diff --git a/src/library_glfw.js b/src/library_glfw.js
index a8815d838af9d..7a07e3633e98d 100644
--- a/src/library_glfw.js
+++ b/src/library_glfw.js
@@ -419,7 +419,7 @@ var LibraryGLFW = {
// This logic comes directly from the sdl implementation. We cannot
// call preventDefault on all keydown events otherwise onKeyPress will
// not get called
- if (event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */) {
+ if (event.key == 'Backspace' || event.key == 'Tab') {
event.preventDefault();
}
},
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 9ab538381b403..27a739a2fff99 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -696,7 +696,7 @@ var LibrarySDL = {
// won't fire. However, it's fine (and in some cases necessary) to
// preventDefault for keys that don't generate a character. Otherwise,
// preventDefault is the right thing to do in general.
- if (event.type !== 'keydown' || (!SDL.unicode && !SDL.textInput) || (event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */)) {
+ if (event.type !== 'keydown' || (!SDL.unicode && !SDL.textInput) || (event.key == 'Backspace' || event.key == 'Tab')) {
event.preventDefault();
}
@@ -930,7 +930,9 @@ var LibrarySDL = {
switch (event.type) {
case 'keydown': case 'keyup': {
var down = event.type === 'keydown';
- //dbg('Received key event: ' + event.keyCode);
+#if RUNTIME_DEBUG
+ dbg('Received key event: ' + event.keyCode);
+#endif
var key = SDL.lookupKeyCodeForEvent(event);
var scan;
if (key >= 1024) {
diff --git a/src/proxyClient.js b/src/proxyClient.js
index a2dc26d56df67..de17f2e549916 100644
--- a/src/proxyClient.js
+++ b/src/proxyClient.js
@@ -313,7 +313,7 @@ if (!ENVIRONMENT_IS_NODE) {
// Only prevent default on backspace/tab because we don't want unexpected navigation.
// Do not prevent default on the rest as we need the keypress event.
function shouldPreventDefault(event) {
- if (event.type === 'keydown' && event.keyCode !== 8 /* backspace */ && event.keyCode !== 9 /* tab */) {
+ if (event.type === 'keydown' && event.key != 'Backspace' && event.key != 'Tab') {
return false; // keypress, back navigation
} else {
return true; // NO keypress, NO back navigation
diff --git a/test/interactive/test_glfw_get_key_stuck.c b/test/interactive/test_glfw_get_key_stuck.c
index 878778fb324b0..409df75777bd7 100644
--- a/test/interactive/test_glfw_get_key_stuck.c
+++ b/test/interactive/test_glfw_get_key_stuck.c
@@ -98,10 +98,10 @@ int main() {
printf("%d. Press and hold spacebar\n", step);
#ifdef __EMSCRIPTEN__
- emscripten_set_blur_callback(NULL, NULL, true, on_focuspocus);
- emscripten_set_focus_callback(NULL, NULL, true, on_focuspocus);
- emscripten_set_focusin_callback(NULL, NULL, true, on_focuspocus);
- emscripten_set_focusout_callback(NULL, NULL, true, on_focuspocus);
+ emscripten_set_blur_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, true, on_focuspocus);
+ emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, true, on_focuspocus);
+ emscripten_set_focusin_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, true, on_focuspocus);
+ emscripten_set_focusout_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, true, on_focuspocus);
emscripten_set_main_loop(render, 0, 1);
__builtin_trap();
diff --git a/test/test_browser.py b/test/test_browser.py
index 8c8062e1b02ce..950dc3c62f602 100644
--- a/test/test_browser.py
+++ b/test/test_browser.py
@@ -1013,15 +1013,15 @@ def post():