| 1 | package input |
| 2 | |
| 3 | // KeyMod represents modifier keys. |
| 4 | type KeyMod int |
| 5 | |
| 6 | // Modifier keys. |
| 7 | const ( |
| 8 | ModShift KeyMod = 1 << iota |
| 9 | ModAlt |
| 10 | ModCtrl |
| 11 | ModMeta |
| 12 | |
| 13 | // These modifiers are used with the Kitty protocol. |
| 14 | // XXX: Meta and Super are swapped in the Kitty protocol, |
| 15 | // this is to preserve compatibility with XTerm modifiers. |
| 16 | |
| 17 | ModHyper |
| 18 | ModSuper // Windows/Command keys |
| 19 | |
| 20 | // These are key lock states. |
| 21 | |
| 22 | ModCapsLock |
| 23 | ModNumLock |
| 24 | ModScrollLock // Defined in Windows API only |
| 25 | ) |
| 26 | |
| 27 | // Contains reports whether m contains the given modifiers. |
| 28 | // |
| 29 | // Example: |
| 30 | // |
| 31 | // m := ModAlt | ModCtrl |
| 32 | // m.Contains(ModCtrl) // true |
| 33 | // m.Contains(ModAlt | ModCtrl) // true |
| 34 | // m.Contains(ModAlt | ModCtrl | ModShift) // false |
| 35 | func (m KeyMod) Contains(mods KeyMod) bool { |
| 36 | return m&mods == mods |
| 37 | } |