mod.go 771 B

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