diff --git a/key.go b/key.go index f6233ee..6718cc6 100644 --- a/key.go +++ b/key.go @@ -78,6 +78,7 @@ const ( // Aliases const ( + KeyNull = keyNUL KeyBreak = keyETX KeyEnter = keyCR KeyBackspace = keyBS @@ -220,6 +221,12 @@ func ReadKey(r io.Reader) (Key, error) { return Key{Type: k}, nil } + // If the first byte is an escape sequence, and we're still here, just + // send a null to avoid sending bizarre escape sequences down the line + if n > 0 && buf[0] == 0x1b { + return Key{Type: KeyNull}, nil + } + // Nope, just a regular, ol' rune return Key{Type: KeyRune, Rune: c}, nil }