//! USB HID keyboard usages: SDL scancodes use them, and browsers map //! `KeyboardEvent.code` onto them, so recordings mean the same key everywhere. pub const Key = enum(u8) { a = 4, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"0", @"return", escape, backspace, tab, space, minus, equals, left_bracket, right_bracket, backslash, semicolon = 51, apostrophe, grave, comma, period, slash, f1 = 58, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, home = 74, page_up, delete, end, page_down, right, left, down, up, keypad_enter = 88, return2 = 158, left_ctrl = 224, left_shift, left_alt, left_gui, right_ctrl, right_shift, right_alt, right_gui, _, pub const Mod = struct { pub const shift: u32 = 1; pub const ctrl: u32 = 2; pub const alt: u32 = 4; pub const gui: u32 = 8; }; pub fn isEnter(key: Key) bool { return key == .@"return" or key == .keypad_enter or key == .return2; } }; test "HID values match the specification's anchors" { const std = @import("std"); try std.testing.expectEqual(4, @backingInt(Key.a)); try std.testing.expectEqual(39, @backingInt(Key.@"0")); try std.testing.expectEqual(53, @backingInt(Key.grave)); try std.testing.expectEqual(82, @backingInt(Key.up)); }