From d206949f6258db36060af3e84fdae15cb7b9a45c Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 8 Nov 2016 03:07:26 +0900 Subject: [PATCH] Wait for additional keys after ESC for up to 100ms Close #661 --- src/tui/ncurses.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tui/ncurses.go b/src/tui/ncurses.go index d55c1c8..16a29fc 100644 --- a/src/tui/ncurses.go +++ b/src/tui/ncurses.go @@ -295,13 +295,24 @@ func getch(nonblock bool) int { func GetBytes() []byte { c := getch(false) + retries := 0 + if c == 27 { + // Wait for additional keys after ESC for 100ms (10 * 10ms) + retries = 10 + } _buf = append(_buf, byte(c)) for { c = getch(true) if c == -1 { + if retries > 0 { + retries-- + time.Sleep(10 * time.Millisecond) + continue + } break } + retries = 0 _buf = append(_buf, byte(c)) }