Peter Hodge wrote:
Hello all,
I am having trouble with getchar() detecting <ESC>. If I use getchar(0) or
getchar(1), it will not pick up an <ESC> keystroke. You can replicate this by
using the command:
:sleep 3 | echo getchar(0)
... and pressing <ESC> quickly before the getchar() function is called. In GUI
Vim, I correctly see 27 returned by getchar(0), but in Terminal Vim, getchar(0)
is returning '0', even though <ESC> has been pressed. Is this a bug in Vim?
regards,
Peter
Here, it depends of the number of keypresses:
In gvim, ":sleep 10 | echo getchar(0)" followed by Esc returns 27 with no beep
after 10 seconds. If Esc is pressed twice during the sleep period, it returns
27 with one beep after 10 seconds.
In console Vim (with the same executable), ":sleep 10 | echo getchar(0)"
followed by Esc returns 0 with one beep after 10 seconds. If Esc is hit twice
during the sleep period, it returns 27 with one beep after 10 seconds.
I suspect the difference may be due to the fact that many special keys
generate (in console terminals but not in gvim) byte sequences starting with
Esc, so the Esc key is not really "seen" until the next byte has been input.
Hitting <Del> in konsole during the sleep period gives me <80>kD with no beep,
not the raw keycode, which would have been ^[[3~
":set timeout timeoutlen=5000 ttimeoutlen=250" apparently doesn't make any
difference.
Best regards,
Tony.