Skip to content

Commit

Permalink
Use key.Button type in button constants
Browse files Browse the repository at this point in the history
Code editors will better suggest parameters accepted by key.Btn and key.Btnp functions.
  • Loading branch information
elgopher committed Mar 24, 2023
1 parent 60273fc commit fbd996b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 73 deletions.
2 changes: 1 addition & 1 deletion ebitengine/keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/elgopher/pi/key"
)

var keyMapping = map[int]ebiten.Key{
var keyMapping = map[key.Button]ebiten.Key{
key.Shift: ebiten.KeyShift,
key.Ctrl: ebiten.KeyControl,
key.Alt: ebiten.KeyAlt,
Expand Down
144 changes: 72 additions & 72 deletions key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,78 +27,78 @@ import (
type Button int

const (
Shift = 1
Ctrl = 3
Alt = 5 // Please note that on some keyboard layouts on Windows the right alt is a combination of Ctrl+Alt
Cap = 7
Back = '\b' // 8
Tab = '\t' // 9
Enter = '\n' // 10
F1 = 11
F2 = 12
F3 = 13
F4 = 14
F5 = 15
F6 = 16
F7 = 17
F8 = 18
F9 = 19
F10 = 20
F11 = 21
F12 = 22
Left = 23
Right = 24
Up = 25
Down = 26
Esc = 27
Space = ' ' // 32
Apostrophe = '\'' // 39
Comma = ',' // 44
Minus = '-' // 45
Period = '.' // 46
Slash = '/' // 47
Digit0 = '0' // 48
Digit1 = '1' // 49
Digit2 = '2' // 50
Digit3 = '3' // 51
Digit4 = '4' // 52
Digit5 = '5' // 53
Digit6 = '6' // 54
Digit7 = '7' // 55
Digit8 = '8' // 56
Digit9 = '9' // 57
Semicolon = ';' // 59
Equal = '=' // 61
A = 'A' // 65
B = 'B' // 66
C = 'C' // 67
D = 'D' // 68
E = 'E' // 69
F = 'F' // 70
G = 'G' // 71
H = 'H' // 72
I = 'I' // 73
J = 'J' // 74
K = 'K' // 75
L = 'L' // 76
M = 'M' // 77
N = 'N' // 78
O = 'O' // 79
P = 'P' // 80
Q = 'Q' // 81
R = 'R' // 82
S = 'S' // 83
T = 'T' // 84
U = 'U' // 85
V = 'V' // 86
W = 'W' // 87
X = 'X' // 88
Y = 'Y' // 89
Z = 'Z' // 90
BracketLeft = '[' // 91
Backslash = '\\' // 92
BracketRight = ']' // 93
Backquote = '`' // 96
Shift Button = 1
Ctrl Button = 3
Alt Button = 5 // Please note that on some keyboard layouts on Windows the right alt is a combination of Ctrl+Alt
Cap Button = 7
Back Button = '\b' // 8
Tab Button = '\t' // 9
Enter Button = '\n' // 10
F1 Button = 11
F2 Button = 12
F3 Button = 13
F4 Button = 14
F5 Button = 15
F6 Button = 16
F7 Button = 17
F8 Button = 18
F9 Button = 19
F10 Button = 20
F11 Button = 21
F12 Button = 22
Left Button = 23
Right Button = 24
Up Button = 25
Down Button = 26
Esc Button = 27
Space Button = ' ' // 32
Apostrophe Button = '\'' // 39
Comma Button = ',' // 44
Minus Button = '-' // 45
Period Button = '.' // 46
Slash Button = '/' // 47
Digit0 Button = '0' // 48
Digit1 Button = '1' // 49
Digit2 Button = '2' // 50
Digit3 Button = '3' // 51
Digit4 Button = '4' // 52
Digit5 Button = '5' // 53
Digit6 Button = '6' // 54
Digit7 Button = '7' // 55
Digit8 Button = '8' // 56
Digit9 Button = '9' // 57
Semicolon Button = ';' // 59
Equal Button = '=' // 61
A Button = 'A' // 65
B Button = 'B' // 66
C Button = 'C' // 67
D Button = 'D' // 68
E Button = 'E' // 69
F Button = 'F' // 70
G Button = 'G' // 71
H Button = 'H' // 72
I Button = 'I' // 73
J Button = 'J' // 74
K Button = 'K' // 75
L Button = 'L' // 76
M Button = 'M' // 77
N Button = 'N' // 78
O Button = 'O' // 79
P Button = 'P' // 80
Q Button = 'Q' // 81
R Button = 'R' // 82
S Button = 'S' // 83
T Button = 'T' // 84
U Button = 'U' // 85
V Button = 'V' // 86
W Button = 'W' // 87
X Button = 'X' // 88
Y Button = 'Y' // 89
Z Button = 'Z' // 90
BracketLeft Button = '[' // 91
Backslash Button = '\\' // 92
BracketRight Button = ']' // 93
Backquote Button = '`' // 96
)

// Duration has info how many frames in a row a keyboard button was pressed:
Expand Down

0 comments on commit fbd996b

Please sign in to comment.