diff options
-rw-r--r-- | src/library_sdl.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index 580330e8..a74dc785 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -550,9 +550,10 @@ var LibrarySDL = { SDL_Init: function(what) { SDL.startTime = Date.now(); - ['keydown', 'keyup'].forEach(function(event) { - addEventListener(event, SDL.receiveEvent, true); - }); + // capture all key events. we just keep down and up, but also capture press to prevent default actions + document.onkeydown = SDL.receiveEvent; + document.onkeyup = SDL.receiveEvent; + document.onkeypress = SDL.receiveEvent; SDL.keyboardState = _malloc(0x10000); _memset(SDL.keyboardState, 0, 0x10000); // Initialize this structure carefully for closure |