diff options
Diffstat (limited to 'packages/tui/input/mod.go')
| -rw-r--r-- | packages/tui/input/mod.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/packages/tui/input/mod.go b/packages/tui/input/mod.go new file mode 100644 index 000000000..c00762769 --- /dev/null +++ b/packages/tui/input/mod.go @@ -0,0 +1,37 @@ +package input + +// KeyMod represents modifier keys. +type KeyMod int + +// Modifier keys. +const ( + ModShift KeyMod = 1 << iota + ModAlt + ModCtrl + ModMeta + + // These modifiers are used with the Kitty protocol. + // XXX: Meta and Super are swapped in the Kitty protocol, + // this is to preserve compatibility with XTerm modifiers. + + ModHyper + ModSuper // Windows/Command keys + + // These are key lock states. + + ModCapsLock + ModNumLock + ModScrollLock // Defined in Windows API only +) + +// Contains reports whether m contains the given modifiers. +// +// Example: +// +// m := ModAlt | ModCtrl +// m.Contains(ModCtrl) // true +// m.Contains(ModAlt | ModCtrl) // true +// m.Contains(ModAlt | ModCtrl | ModShift) // false +func (m KeyMod) Contains(mods KeyMod) bool { + return m&mods == mods +} |
