package matrix
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/matrix.input/Input/Key/index.html
Module Input.KeySource
Keyboard 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.
Keys
type t = | Char of Uchar.t(*Unicode character, including control characters (e.g.
*)Uchar.of_int 0x03for Ctrl+C).| Enter| Line_feed| Tab| Backspace| Delete| Escape| Up| Down| Left| Right| Home| End| Page_up| Page_down| Insert| F of int(*Function 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_0(*Keypad 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 int(*Unknown key code from Private Use Area or unmapped sequences. The
*)intis the Kitty protocol key code.
The type for keyboard keys.
Predicates and comparisons
is_ctrl_char k is true iff k is a Char in the ASCII control range U+0000..U+001F or U+007F (DEL).
Formatting
pp formats keys for debugging.
Event types
Modifiers
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.
Key events
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).
*)Noneon legacy terminals.base_key : Uchar.t option;(*Key without modifiers (Kitty protocol only).
*)Noneon 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:
modifierdefaults tono_modifier.event_typedefaults toPress.associated_textdefaults to"".shifted_keydefaults toNone.base_keydefaults toNone.
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.
Event predicates and comparisons
equal_event a b is true iff all fields of a and b are structurally equal.
pp_event formats key events for debugging.