| | |
| | | |
| | | import ( |
| | | "fmt" |
| | | "runtime" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | IsAnyOtherKeyPressed(excludeVK int) bool |
| | | // IsAnyOtherKeyPressedSince returns true if another key was pressed after since. |
| | | IsAnyOtherKeyPressedSince(excludeVK int, since time.Time) bool |
| | | // Close releases listener resources. |
| | | Close() |
| | | } |
| | | |
| | | // New creates a new platform-specific hotkey listener. |
| | |
| | | |
| | | // GetKeyName returns the display name for a virtual key code. |
| | | func GetKeyName(vk int) string { |
| | | return GetKeyNameForPlatform(vk, runtime.GOOS) |
| | | } |
| | | |
| | | func GetKeyNameForPlatform(vk int, goos string) string { |
| | | switch vk { |
| | | case 0: |
| | | return "" |
| | | case 0x11: |
| | | return "Ctrl" |
| | | case 0xA2: |
| | |
| | | case 0x0D: |
| | | return "Enter" |
| | | case 0x5B: |
| | | if goos == "darwin" { |
| | | return "L-⌘" |
| | | } |
| | | return "L-Win" |
| | | case 0x5C: |
| | | if goos == "darwin" { |
| | | return "R-⌘" |
| | | } |
| | | return "R-Win" |
| | | case 0x1B: |
| | | return "Esc" |