nsf / termbox

Library for writing text-based user interfaces
http://code.google.com/p/termbox
MIT License
1.96k stars 185 forks source link

ESC considered to be F1 in keyboard events #88

Closed QingYun closed 7 years ago

QingYun commented 7 years ago

Hi! I'm new here and I'm trying to make the output demo work in a GNOME terminal. The while loop in the main function clearly shows that it should exit when the ESC key is pressed, but it doesn't work. I always get a 0xFFFF as ev.key instead of TB_KEY_ESC.

I believe the problem is in the extract_event, which calls parse_escape_seq when the first character of the input buffer is ESC. The parse_escape_seq will then find this single-character buffer matches the first sequence in the keys array, which is F1.

I added a len > 1 condition above the call to parse_escape_seq as a workaround. Not sure if I've done anything wrong as such a fundamental feature should be broken.

nsf commented 7 years ago

I probably should revert this patch: https://github.com/nsf/termbox/commit/6dfe8a0a79b0d94005dec7cf1b4f27824e49d1a2

Right? What do you think?

nsf commented 7 years ago

Sorry for applying that patch without properly testing it.