diff --git a/src/Key.zig b/src/Key.zig index e1770ff..2e7c54d 100644 --- a/src/Key.zig +++ b/src/Key.zig @@ -259,6 +259,124 @@ pub const right_meta: u21 = 57452; pub const iso_level_3_shift: u21 = 57453; pub const iso_level_5_shift: u21 = 57454; +pub const name_map = std.ComptimeStringMap(u21, .{ + // common names + .{ "plus", '+' }, + .{ "minus", '-' }, + .{ "colon", ':' }, + .{ "semicolon", ';' }, + .{ "comma", ',' }, + + // special keys + .{ "insert", insert }, + .{ "delete", delete }, + .{ "left", left }, + .{ "right", right }, + .{ "up", up }, + .{ "down", down }, + .{ "page_up", page_up }, + .{ "page_down", page_down }, + .{ "home", home }, + .{ "end", end }, + .{ "caps_lock", caps_lock }, + .{ "scroll_lock", scroll_lock }, + .{ "num_lock", num_lock }, + .{ "print_screen", print_screen }, + .{ "pause", pause }, + .{ "menu", menu }, + .{ "f1", f1 }, + .{ "f2", f2 }, + .{ "f3", f3 }, + .{ "f4", f4 }, + .{ "f5", f5 }, + .{ "f6", f6 }, + .{ "f7", f7 }, + .{ "f8", f8 }, + .{ "f9", f9 }, + .{ "f10", f10 }, + .{ "f11", f11 }, + .{ "f12", f12 }, + .{ "f13", f13 }, + .{ "f14", f14 }, + .{ "f15", f15 }, + .{ "f16", @"f16" }, + .{ "f17", f17 }, + .{ "f18", f18 }, + .{ "f19", f19 }, + .{ "f20", f20 }, + .{ "f21", f21 }, + .{ "f22", f22 }, + .{ "f23", f23 }, + .{ "f24", f24 }, + .{ "f25", f25 }, + .{ "f26", f26 }, + .{ "f27", f27 }, + .{ "f28", f28 }, + .{ "f29", f29 }, + .{ "f30", f30 }, + .{ "f31", f31 }, + .{ "f32", @"f32" }, + .{ "f33", f33 }, + .{ "f34", f34 }, + .{ "f35", f35 }, + .{ "kp_0", kp_0 }, + .{ "kp_1", kp_1 }, + .{ "kp_2", kp_2 }, + .{ "kp_3", kp_3 }, + .{ "kp_4", kp_4 }, + .{ "kp_5", kp_5 }, + .{ "kp_6", kp_6 }, + .{ "kp_7", kp_7 }, + .{ "kp_8", kp_8 }, + .{ "kp_9", kp_9 }, + .{ "kp_decimal", kp_decimal }, + .{ "kp_divide", kp_divide }, + .{ "kp_multiply", kp_multiply }, + .{ "kp_subtract", kp_subtract }, + .{ "kp_add", kp_add }, + .{ "kp_enter", kp_enter }, + .{ "kp_equal", kp_equal }, + .{ "kp_separator", kp_separator }, + .{ "kp_left", kp_left }, + .{ "kp_right", kp_right }, + .{ "kp_up", kp_up }, + .{ "kp_down", kp_down }, + .{ "kp_page_up", kp_page_up }, + .{ "kp_page_down", kp_page_down }, + .{ "kp_home", kp_home }, + .{ "kp_end", kp_end }, + .{ "kp_insert", kp_insert }, + .{ "kp_delete", kp_delete }, + .{ "kp_begin", kp_begin }, + .{ "media_play", media_play }, + .{ "media_pause", media_pause }, + .{ "media_play_pause", media_play_pause }, + .{ "media_reverse", media_reverse }, + .{ "media_stop", media_stop }, + .{ "media_fast_forward", media_fast_forward }, + .{ "media_rewind", media_rewind }, + .{ "media_track_next", media_track_next }, + .{ "media_track_previous", media_track_previous }, + .{ "media_record", media_record }, + .{ "lower_volume", lower_volume }, + .{ "raise_volume", raise_volume }, + .{ "mute_volume", mute_volume }, + .{ "left_shift", left_shift }, + .{ "left_control", left_control }, + .{ "left_alt", left_alt }, + .{ "left_super", left_super }, + .{ "left_hyper", left_hyper }, + .{ "left_meta", left_meta }, + .{ "right_shift", right_shift }, + .{ "right_control", right_control }, + .{ "right_alt", right_alt }, + .{ "right_super", right_super }, + .{ "right_hyper", right_hyper }, + .{ "right_meta", right_meta }, + .{ "iso_level_3_shift", iso_level_3_shift }, + .{ "iso_level_5_shift", iso_level_5_shift }, +}); + test "matches 'a'" { const key: Key = .{ .codepoint = 'a',