add symbol keys for platform/keyboard
This commit is contained in:
parent
c2689effd9
commit
f2727eac4f
|
@ -47,6 +47,11 @@ const (
|
|||
const (
|
||||
Escape = 27
|
||||
Spacebar = 32
|
||||
Hyphen = 45
|
||||
Asterisk = 42
|
||||
Plus = 43
|
||||
Slash = 47
|
||||
Dot = 46
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -91,6 +96,31 @@ func Parse(input bytes) KeyEvent {
|
|||
event.Key = Escape
|
||||
}
|
||||
|
||||
// Hyphen
|
||||
if code == Hyphen {
|
||||
event.Key = Hyphen
|
||||
}
|
||||
|
||||
// Asterisk
|
||||
if code == Asterisk {
|
||||
event.Key = Asterisk
|
||||
}
|
||||
|
||||
// Plus
|
||||
if code == Plus {
|
||||
event.Key = Plus
|
||||
}
|
||||
|
||||
// Slash
|
||||
if code == Slash {
|
||||
event.Key = Slash
|
||||
}
|
||||
|
||||
// Dot
|
||||
if code == Dot {
|
||||
event.Key = Dot
|
||||
}
|
||||
|
||||
// number keys
|
||||
if code >= 48 && code <= 57 {
|
||||
event.Key = int(code)
|
||||
|
|
|
@ -14,6 +14,26 @@ func TestParseEscape(t *testing.T) {
|
|||
gobottest.Assert(t, Parse(bytes{27, 0, 0}).Key, Escape)
|
||||
}
|
||||
|
||||
func TestParseHyphen(t *testing.T) {
|
||||
gobottest.Assert(t, Parse(bytes{45, 0, 0}).Key, Escape)
|
||||
}
|
||||
|
||||
func TestParseAsterisk(t *testing.T) {
|
||||
gobottest.Assert(t, Parse(bytes{42, 0, 0}).Key, Escape)
|
||||
}
|
||||
|
||||
func TestParsePlus(t *testing.T) {
|
||||
gobottest.Assert(t, Parse(bytes{43, 0, 0}).Key, Escape)
|
||||
}
|
||||
|
||||
func TestParseSlash(t *testing.T) {
|
||||
gobottest.Assert(t, Parse(bytes{47, 0, 0}).Key, Escape)
|
||||
}
|
||||
|
||||
func TestParseDot(t *testing.T) {
|
||||
gobottest.Assert(t, Parse(bytes{46, 0, 0}).Key, Escape)
|
||||
}
|
||||
|
||||
func TestParseNotEscape(t *testing.T) {
|
||||
gobottest.Refute(t, Parse(bytes{27, 91, 65}).Key, Escape)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue