 +      reinterpret_cast<pp::MouseInputEvent*>(input_event);
 +    event->x = mouse_event->GetPosition().x();
 +    event->y = mouse_event->GetPosition().y();
-+  } else if (event->type == PP_INPUTEVENT_TYPE_KEYDOWN || 
++  } else if (event->type == PP_INPUTEVENT_TYPE_KEYDOWN ||
 +             event->type == PP_INPUTEVENT_TYPE_KEYUP ||
 +             event->type == PP_INPUTEVENT_TYPE_CHAR) {
 +    // PPAPI sends us separate events for KEYDOWN and CHAR; the first one

+    keysym.scancode = keyboard_event->GetKeyCode();
+    keysym.unicode = keyboard_event->GetCharacterText().AsString()[0];
+    keysym.sym = translateKey(keysym.scancode);
+    if (event->type == PP_INPUTEVENT_TYPE_KEYDOWN &&
+        keysym.sym >= ' ' &&  keysym.sym <= 126) return;
+    if (event->type == PP_INPUTEVENT_TYPE_CHAR &&
+        keysym.unicode >= ' ' &&  keysym.unicode <= 126) {
+      keysym.scancode = toupper(static_cast<char>(keysym.unicode));
+      keysym.sym = static_cast<SDLKey>(keysym.unicode);
+    }
+    keysym.mod = KMOD_NONE;
+    event->keysym = keysym;

+  }
+}
+
+// Translate ASCII code to browser keycode
+static uint8_t translateAscii(uint8_t ascii) {
+  if ('A' <= ascii && ascii <= 'Z') {
+    return ascii;
+  } else if ('a' <= ascii && ascii <= 'z') {
+    return toupper(ascii);
+  } else if ('0' <= ascii && ascii <= '9') {
+    return ascii;
+  } else if (' ' == ascii || '\r' == ascii || '\t' == ascii ||
+             '\x1b' == ascii || '\b' == ascii) {
+    return ascii;
+  } else {
+    switch (ascii) {
+      case '!': return '1';
+      case '@': return '2';
+      case '#': return '3';
+      case '$': return '4';
+      case '%': return '5';
+      case '^': return '6';
+      case '&': return '7';
+      case '*': return '8';
+      case '(': return '9';
+      case ')': return '0';
+      case ';': case ':': return 186;
+      case '=': case '+': return 187;
+      case ',': case '<': return 188;
+      case '-': case '_': return 189;
+      case '.': case '>': return 190;
+      case '/': case '?': return 191;
+      case '`': case '~': return 192;
+      case '[': case '{': return 219;
+      case '\\': case '|': return 220;
+      case ']': case '}': return 221;
+      case '\'': case '"': return 222;
+      default:
+        break;
+    }
+  }
+  return 0;
+}
+
+// Translate browser keycode to SDLKey
+static SDLKey translateKey(uint32_t code) {
+  if (code >= 'A' && code <= 'Z')
+    return (SDLKey)(code - 'A' + SDLK_a);
