-
Notifications
You must be signed in to change notification settings - Fork 1
/
keys.go
89 lines (83 loc) · 2.08 KB
/
keys.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package console
import (
"fmt"
"github.com/eiannone/keyboard"
)
// Key represents a key.
type Key keyboard.Key
const (
// KeyEscape represents the escape key
KeyEscape = Key(keyboard.KeyEsc)
// KeyCtrlC represents the key combination Ctrl+C
KeyCtrlC = Key(keyboard.KeyCtrlC)
// KeyCtrlW represents the key combination Ctrl+W
KeyCtrlW = Key(keyboard.KeyCtrlW)
// KeyCtrlS represents the key combination Ctrl+S
KeyCtrlS = Key(keyboard.KeyCtrlS)
// KeyUp represents the arrow up key
KeyUp = Key(keyboard.KeyArrowUp)
// KeyDown represents the arrow down key
KeyDown = Key(keyboard.KeyArrowDown)
// KeyLeft represents the arrow left key
KeyLeft = Key(keyboard.KeyArrowLeft)
// KeyRight represents the arrow right key
KeyRight = Key(keyboard.KeyArrowRight)
// KeyHome represents the home (Pos1) key
KeyHome = Key(keyboard.KeyHome)
// KeyEnd represents the end key
KeyEnd = Key(keyboard.KeyEnd)
// KeyPageUp represents the page up key
KeyPageUp = Key(keyboard.KeyPgup)
// KeyPageDown represents the page down key
KeyPageDown = Key(keyboard.KeyPgdn)
// KeyBackspace represents the backspace key
KeyBackspace = Key(keyboard.KeyBackspace2)
// KeyDelete represents the delete key
KeyDelete = Key(keyboard.KeyDelete)
// KeyEnter represents the enter key
KeyEnter = Key(keyboard.KeyEnter)
// KeyTab represents the tabulator key
KeyTab = Key(keyboard.KeyTab)
// KeySpace represents the space key
KeySpace = Key(keyboard.KeySpace)
)
func (k Key) String() string {
switch k {
case KeyEscape:
return "Escape"
case KeyCtrlC:
return "CtrlC"
case KeyCtrlW:
return "Ctrlw"
case KeyCtrlS:
return "CtrlS"
case KeyUp:
return "ArrowUp"
case KeyDown:
return "ArrowDown"
case KeyLeft:
return "ArrowLeft"
case KeyRight:
return "ArrowRight"
case KeyHome:
return "Home"
case KeyEnd:
return "End"
case KeyPageUp:
return "PageUp"
case KeyPageDown:
return "PageDown"
case KeyBackspace:
return "Backspace"
case KeyDelete:
return "Delete"
case KeyEnter:
return "Enter"
case KeyTab:
return "Tab"
case KeySpace:
return "Space"
default:
return fmt.Sprintf("Key[%d]", k)
}
}