Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard input corrupted when scrolling in python on a macintosh #78

Open
dj-on-github opened this issue Aug 7, 2016 · 2 comments
Open

Comments

@dj-on-github
Copy link

dj-on-github commented Aug 7, 2016

scrolltest.txt
I found my termbox based program was quitting when scrolling with the touchpad on a macbook.
I traced this to the program receiving ESCs while scrolling, when it should only be getting arrow up or down events.

I wrote a test case that gets counts the events.
Run it, scroll up a few times, then press X to quit and print the results.
Without a time delay in the loop, this works fine. You only get up arrow events.
I added a time delay in the loop to simulate the delay in updating the view in my program. Then 3 other different events are received, including ESC.

Without delay..
$ ./scrolltest.py
(1, None, 65516, 0, 0, 0, 0, 0) : 14

With delay..
./scrolltest.py
(1, u'O', 0, 0, 0, 0, 0, 0) : 1
(1, u'B', 0, 0, 0, 0, 0, 0) : 1
(1, None, 65516, 0, 0, 0, 0, 0) : 104
(1, None, 27, 0, 0, 0, 0, 0) : 1

So something is up with the event handling. It seems to be chopping up the escape sequences into smaller chunks before they are interpreted as key strokes.

scrolltest.py...

@nsf
Copy link
Owner

nsf commented Aug 7, 2016

Yeah, sadly it's a known fact on osx: nsf/termbox-go#132. Not sure what to do about it.

@rationull
Copy link

The linked termbox-go issue was resolved by adding a short wait when an incomplete escape sequence is encountered. The Escape keypress event is only emitted If the wait elapses before any more characters are encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants