aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-08-29 11:37:53 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-08-29 11:37:53 -0700
commit68d25630a8cf813c58d693e0fb876e6b39531b3d (patch)
tree84a87c3b31b1350dc99c97c0d2f672519642293d /src
parent134099a4e630ccdbaaa6116a520d83794433aab5 (diff)
full capture keyboard events in sdl, to prevent default actions entirely
Diffstat (limited to 'src')
-rw-r--r--src/library_sdl.js7
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