Input.KeySourceKeyboard keys.
Most keys map to dedicated constructors. Char handles all Unicode characters including control codes. Keypad keys (KP_*) are reported when the terminal sends distinct codes for keypad versus main keyboard. Unknown captures unrecognized Kitty protocol key codes for forward compatibility.
type t = | Char of Uchar.tUnicode character, including control characters (e.g. Uchar.of_int 0x03 for Ctrl+C).
| Enter| Line_feed| Tab| Backspace| Delete| Escape| Up| Down| Left| Right| Home| End| Page_up| Page_down| Insert| F of intFunction key. Values outside [1;35] may appear from the Kitty protocol.
*)| Print_screen| Pause| Menu| Scroll_lock| Media_play| Media_pause| Media_play_pause| Media_stop| Media_reverse| Media_fast_forward| Media_rewind| Media_next| Media_prev| Media_record| Volume_up| Volume_down| Volume_mute| Shift_left| Shift_right| Ctrl_left| Ctrl_right| Alt_left| Alt_right| Super_left| Super_right| Hyper_left| Hyper_right| Meta_left| Meta_right| Iso_level3_shift| Iso_level5_shift| Caps_lock| Num_lock| KP_0Keypad keys. Reported when the terminal sends distinct codes for keypad versus main keyboard.
*)| KP_1| KP_2| KP_3| KP_4| KP_5| KP_6| KP_7| KP_8| KP_9| KP_decimal| KP_divide| KP_multiply| KP_subtract| KP_add| KP_enter| KP_equal| KP_separator| KP_begin| KP_left| KP_right| KP_up| KP_down| KP_page_up| KP_page_down| KP_home| KP_end| KP_insert| KP_delete| Unknown of intUnknown key code from Private Use Area or unmapped sequences. The int is the Kitty protocol key code.
The type for keyboard keys.
is_ctrl_char k is true iff k is a Char in the ASCII control range U+0000..U+001F or U+007F (DEL).
pp formats keys for debugging.
type modifier = {ctrl : bool;Control key held.
*)alt : bool;Alt/Option key held.
*)shift : bool;Shift key held.
*)super : bool;Super/Windows/Command key held.
*)hyper : bool;Hyper modifier key held.
*)meta : bool;Meta modifier key held.
*)caps_lock : bool;Caps Lock toggle is active.
*)num_lock : bool;Num Lock toggle is active.
*)}The type for modifier state.
Lock fields (caps_lock, num_lock) indicate toggle state, not whether the physical key is currently pressed.
no_modifier is a modifier with all fields set to false. Useful as a base value: {no_modifier with ctrl = true}.
equal_modifier a b is true iff all fields of a and b are equal.
pp_modifier formats modifier sets for debugging.
type event = {key : t;The key.
*)modifier : modifier;Active modifiers.
*)event_type : event_type;Press, repeat or release.
*)associated_text : string;UTF-8 text to insert. Populated by the Kitty protocol for text-producing keys and by the parser for legacy text bytes. Empty for non-text keys or when not provided.
*)shifted_key : Uchar.t option;Key with Shift applied (Kitty protocol only). None on legacy terminals.
base_key : Uchar.t option;Key without modifiers (Kitty protocol only). None on legacy terminals.
}The type for key events. On legacy terminals event_type is always Press, and shifted_key and base_key are None.
val make :
?modifier:modifier ->
?event_type:event_type ->
?associated_text:string ->
?shifted_key:Uchar.t ->
?base_key:Uchar.t ->
t ->
eventmake key is a key event for key with:
modifier defaults to no_modifier.event_type defaults to Press.associated_text defaults to "".shifted_key defaults to None.base_key defaults to None.val of_char :
?modifier:modifier ->
?event_type:event_type ->
?associated_text:string ->
?shifted_key:Uchar.t ->
?base_key:Uchar.t ->
char ->
eventof_char c is like make with Char (Uchar.of_char c).
When associated_text is not provided it defaults to a single-character string for c. Uses shared strings for ASCII characters to reduce allocations.
equal_event a b is true iff all fields of a and b are structurally equal.
pp_event formats key events for debugging.