Skip to content

Latest commit

 

History

History
81 lines (62 loc) · 3.37 KB

KeyboardHandler.md

File metadata and controls

81 lines (62 loc) · 3.37 KB

API categories | API index

KeyboardHandler (interface)

This handler allows you to handle events related to keyboard input and is called only for the main frame. For an example of how to implement handler see cefpython.CreateBrowser().

Table of contents:

Callbacks

OnPreKeyEvent

Parameter Type
browser Browser
event KeyEvent
eventHandle MSG* / GdkEvent* / NSEvent*`
isKeyboardShortcutOut out list[0] -> bool
Return void

Called before a keyboard event is sent to the renderer. |event| contains information about the keyboard event. |eventHandle| is the operating system event message, if any. Return true if the event was handled or false otherwise. If the event will be handled in OnKeyEvent() as a keyboard shortcut, set isKeyboardShortcutOut[0] to True and return False.

KeyEvent is a dictionary with the following keys:

Key Type Description
type KeyEventType The type of keyboard event
modifiers KeyEventFlags Bit flags describing any pressed modifier keys
windows_key_code int The Windows key code for the key event. This value is used by the DOM specification. Sometimes it comes directly from the event (i.e. on Windows) and sometimes it's determined using a mapping function. See "chromium/KeyboardCodes.h" for a list of values.
native_key_code int The actual key code genenerated by the platform
is_system_key int Indicates whether the event is considered a "system key" event. For Windows see WM_SYSKEYDOWN. This value will always be false on non-Windows platforms.
character wchar_t or unsigned short The character generated by the keystroke
unmodified_character wchar_t or unsigned short Same as 'character' but unmodified by any concurrently-held modifiers (except shift). This is useful for working out shortcut keys.
focus_on_editable_field bool True if the focus is currently on an editable field on the page. This is useful for determining if standard key events should be intercepted.

KeyEventType constants:

  • cefpython.KEYEVENT_RAWKEYDOWN
  • cefpython.KEYEVENT_KEYDOWN
  • cefpython.KEYEVENT_KEYUP
  • cefpython.KEYEVENT_CHAR

KeyEventFlags constants:

  • cefpython.EVENTFLAG_NONE
  • cefpython.EVENTFLAG_CAPS_LOCK_ON
  • cefpython.EVENTFLAG_SHIFT_DOWN
  • cefpython.EVENTFLAG_CONTROL_DOWN
  • cefpython.EVENTFLAG_ALT_DOWN
  • cefpython.EVENTFLAG_LEFT_MOUSE_BUTTON
  • cefpython.EVENTFLAG_MIDDLE_MOUSE_BUTTON
  • cefpython.EVENTFLAG_RIGHT_MOUSE_BUTTON
  • cefpython.EVENTFLAG_COMMAND_DOWN (Mac)
  • cefpython.EVENTFLAG_NUM_LOCK_ON (Mac)
  • cefpython.EVENTFLAG_IS_KEY_PAD (Mac)
  • cefpython.EVENTFLAG_IS_LEFT (Mac)
  • cefpython.EVENTFLAG_IS_RIGHT (Mac)

OnKeyEvent

Parameter Type
browser Browser
event KeyEvent
eventHandle MSG* / GdkEvent* / NSEvent*
Return void

Called after the renderer and javascript in the page has had a chance to handle the event. |event| contains information about the keyboard event. |os_event| is the operating system event message, if any. Return true if the keyboard event was handled or false otherwise. Description of the KeyEvent type is in the OnPreKeyEvent() callback.