Helper function to convert SDL2 key codes to cef ones
(key)
| 417 | |
| 418 | |
| 419 | def get_key_code(key): |
| 420 | """Helper function to convert SDL2 key codes to cef ones""" |
| 421 | key_map = { |
| 422 | sdl2.SDLK_RETURN: 13, |
| 423 | sdl2.SDLK_DELETE: 46, |
| 424 | sdl2.SDLK_BACKSPACE: 8, |
| 425 | sdl2.SDLK_LEFT: 37, |
| 426 | sdl2.SDLK_RIGHT: 39, |
| 427 | sdl2.SDLK_UP: 38, |
| 428 | sdl2.SDLK_DOWN: 40, |
| 429 | sdl2.SDLK_HOME: 36, |
| 430 | sdl2.SDLK_END: 35, |
| 431 | } |
| 432 | if key in key_map: |
| 433 | return key_map[key] |
| 434 | # Key not mapped, raise exception |
| 435 | logging.error( |
| 436 | """ |
| 437 | Keyboard mapping incomplete: unsupported SDL key %d. |
| 438 | See https://wiki.libsdl.org/SDLKeycodeLookup for mapping. |
| 439 | """ % key |
| 440 | ) |
| 441 | return None |
| 442 | |
| 443 | |
| 444 | # The key events on MacOS have different native keycode than on other operating |