vtterm.keys
Turn key presses into the bytes a VT100 sends.
key_bytes maps one key code and modifier mask (the SDL-style codes in
OmniPython’s keys module) to bytes: letters and symbols on a US layout,
Ctrl+letter as a control code, and the arrows, Home, End, Page Up, Page Down,
Insert, Delete and F1 to F4 as escape sequences. KeyEvents reads key-down
events from a function such as a desktop display’s get_events, and mouse
events too when you give it a Mouse.
- vtterm.keys.key_bytes(key, mod=0, app_cursor=False)[source]
Return the bytes a VT100 sends for a key, or
Nonefor a key it doesn’t send.
- vtterm.keys.scroll_key(screen, key, mod)[source]
Page the scrollback for Shift+Page Up or Shift+Page Down.
- class vtterm.keys.KeyEvents(get_events, screen=None, other=None, mouse=None)[source]
Bases:
objectReads key presses from an event function and returns their bytes.
- Parameters:
get_events (callable) – Returns a list of events, such as a desktop display’s
get_events. Events withtype,keyandmodfields that are key-downs are turned into bytes; the rest go tootherif given.screen (Screen) – Its
app_cursormode picks the arrow sequences.other (callable) – Called with each event that isn’t a key-down.
mouse (Mouse) – A
Mousewhose reports for mouse events are returned with the keys’ bytes, in order.