From 24e8dccdca3e71ac50a1fb27c0afb6b57b0d1b9f Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sat, 30 Mar 2024 07:37:54 -0500 Subject: [PATCH] key: add isModifier method --- src/Key.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Key.zig b/src/Key.zig index 40e8437..e1770ff 100644 --- a/src/Key.zig +++ b/src/Key.zig @@ -122,6 +122,22 @@ pub fn matchExact(self: Key, cp: u21, mods: Modifiers) bool { return self.codepoint == cp and std.meta.eql(self.mods, mods); } +/// True if the key is a single modifier (ie: left_shift) +pub fn isModifier(self: Key) bool { + return self.codepoint == left_shift or + self.codepoint == left_alt or + self.codepoint == left_super or + self.codepoint == left_hyper or + self.codepoint == left_control or + self.codepoint == left_meta or + self.codepoint == right_shift or + self.codepoint == right_alt or + self.codepoint == right_super or + self.codepoint == right_hyper or + self.codepoint == right_control or + self.codepoint == right_meta; +} + // a few special keys that we encode as their actual ascii value pub const enter: u21 = 0x0D; pub const tab: u21 = 0x09;