diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-08-29 11:37:53 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-08-29 11:37:53 -0700 |
commit | 68d25630a8cf813c58d693e0fb876e6b39531b3d (patch) | |
tree | 84a87c3b31b1350dc99c97c0d2f672519642293d /src/library_sdl.js | |
parent | 134099a4e630ccdbaaa6116a520d83794433aab5 (diff) |
full capture keyboard events in sdl, to prevent default actions entirely
Diffstat (limited to 'src/library_sdl.js')
-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 |