 +    keysym.scancode = keyboard_event->GetKeyCode();
 +    keysym.unicode = keyboard_event->GetCharacterText().AsString()[0];
 +    keysym.sym = translateKey(keysym.scancode);
-+    if (event->type == PP_INPUTEVENT_TYPE_KEYDOWN) {
++    if (type == PP_INPUTEVENT_TYPE_KEYDOWN) {
++      event.type = SDL_KEYDOWN;
 +      last_scancode = keysym.scancode;
 +      if (keysym.sym >= ' ' &&  keysym.sym <= 126) {
-+        free(event);
 +        return;
 +      }
-+    } else if (event->type == PP_INPUTEVENT_TYPE_CHAR) {
++    } else if (type == PP_INPUTEVENT_TYPE_CHAR) {
++      event.type = SDL_KEYDOWN;
 +      if (keysym.sym >= ' ' &&  keysym.sym <= 126) {
 +        keysym.scancode = translateAscii(keysym.unicode);
 +        keysym.sym = translateKey(keysym.scancode);

 #undef SDL_VIDEO_DRIVER_PHOTON
diff -urN SDL-1.2.14/include/SDL_nacl.h SDL-1.2.14-nacl/include/SDL_nacl.h
--- SDL-1.2.14/include/SDL_nacl.h	1970-01-01 03:00:00.000000000 +0300
+++ SDL-1.2.14-nacl/include/SDL_nacl.h	2012-01-16 12:16:39.460269192 +0400
@@ -0,0 +1,22 @@
+#ifndef _SDL_nacl_h
+#define _SDL_nacl_h
+

+        keysym.sym = translateKey(keysym.scancode);
+      }
+    } else {  // event->type == PP_INPUTEVENT_TYPE_KEYUP
+      event.type = SDL_KEYUP;
+      last_scancode = 0;
+    }
+    keysym.mod = KMOD_NONE;
+    event.key.keysym = keysym;
+    event_queue.PushEvent(copyEvent(&event));
+  } else if (type == PP_INPUTEVENT_TYPE_MOUSEENTER ||
+             type == PP_INPUTEVENT_TYPE_MOUSELEAVE) {
+    event.type = SDL_ACTIVEEVENT;
+    event.active.gain = (type == PP_INPUTEVENT_TYPE_MOUSEENTER) ? 1 : 0;
+    event.active.state = SDL_APPMOUSEFOCUS;
+    event_queue.PushEvent(copyEvent(&event));
+  }
+}
+
+void SDL_NACL_SetHasFocus(bool has_focus) {
+  SDL_Event event;
+  event.type = SDL_ACTIVEEVENT;
+  event.active.gain = has_focus ? 1 : 0;
+  event.active.state = SDL_APPINPUTFOCUS;
+  event_queue.PushEvent(copyEvent(&event));
+}
+
+void SDL_NACL_SetPageVisible(bool is_visible) {
+  SDL_Event event;
+  event.type = SDL_ACTIVEEVENT;
+  event.active.gain = is_visible ? 1 : 0;
+  event.active.state = SDL_APPACTIVE;
+  event_queue.PushEvent(copyEvent(&event));
+}
+
+void NACL_PumpEvents(_THIS) {
+  SDL_Event* event;
+  while (event = event_queue.PopEvent()) {
+    if (event->type == SDL_MOUSEBUTTONDOWN) {
+      SDL_PrivateMouseButton(SDL_PRESSED, event->button.button,
+                             event->button.x, event->button.y);
+    } else if (event->type == SDL_MOUSEBUTTONUP) {
+      SDL_PrivateMouseButton(SDL_RELEASED, event->button.button,
+                             event->button.x, event->button.y);
+    } else if (event->type == SDL_MOUSEMOTION) {
+      SDL_PrivateMouseMotion(0, 0, event->motion.x, event->motion.y);
+    } else if (event->type == SDL_KEYDOWN) {
+      SDL_PrivateKeyboard(SDL_PRESSED, &event->key.keysym);
+    } else if (event->type == SDL_KEYUP) {
+      SDL_PrivateKeyboard(SDL_RELEASED, &event->key.keysym);
+    } else if (event->type == SDL_ACTIVEEVENT) {
+      SDL_PrivateAppActive(event->active.gain, event->active.state);
+    }
+    free(event);
+  }
