Treat space key as a control character (instead of a " ")

This commit is contained in:
Christian Rocha
2020-05-11 19:56:46 -04:00
parent 88e4df4055
commit 72c1a1c0ef

6
key.go
View File

@@ -256,6 +256,12 @@ func ReadKey(r io.Reader) (Key, error) {
return Key{Type: KeyType(char)}, nil
}
// If it's a space treat it like a control character (otherwise it gets
// treated as the character " "
if string(char) == " " {
return Key{Type: KeyType(keySP)}, nil
}
// Is it a special sequence, like an arrow key?
if k, ok := sequences[string(buf[:numBytes])]; ok {
return Key{Type: k}, nil