{"action":"opened","issue":{"url":"https://api.github.com/repos/nsf/termbox/issues/78","repository_url":"https://api.github.com/repos/nsf/termbox","labels_url":"https://api.github.com/repos/nsf/termbox/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/nsf/termbox/issues/78/comments","events_url":"https://api.github.com/repos/nsf/termbox/issues/78/events","html_url":"https://github.com/nsf/termbox/issues/78","id":169776509,"number":78,"title":"Keyboard input corrupted when scrolling in python on a macintosh","user":{"login":"dj-on-github","id":7389465,"avatar_url":"https://avatars.githubusercontent.com/u/7389465?v=3","gravatar_id":"","url":"https://api.github.com/users/dj-on-github","html_url":"https://github.com/dj-on-github","followers_url":"https://api.github.com/users/dj-on-github/followers","following_url":"https://api.github.com/users/dj-on-github/following{/other_user}","gists_url":"https://api.github.com/users/dj-on-github/gists{/gist_id}","starred_url":"https://api.github.com/users/dj-on-github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dj-on-github/subscriptions","organizations_url":"https://api.github.com/users/dj-on-github/orgs","repos_url":"https://api.github.com/users/dj-on-github/repos","events_url":"https://api.github.com/users/dj-on-github/events{/privacy}","received_events_url":"https://api.github.com/users/dj-on-github/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-07T02:38:05Z","updated_at":"2016-08-07T02:38:05Z","closed_at":null,"body":"I found my termbox based program was quitting when scrolling with the touchpad on a macbook.\r\nI traced this to the program receiving ESCs while scrolling, when it should only be getting arrow up or down events.\r\n\r\nI wrote a test case that gets counts the events.\r\nRun it, scroll up a few times, then press X to quit and print the results.\r\nWithout a time delay in the loop, this works fine. You only get up arrow events.\r\nI 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.\r\n\r\nWithout delay..\r\n$ ./scrolltest.py \r\n(1, None, 65516, 0, 0, 0, 0, 0) : 14\r\n\r\nWith delay..\r\n./scrolltest.py \r\n(1, u'O', 0, 0, 0, 0, 0, 0) : 1\r\n(1, u'B', 0, 0, 0, 0, 0, 0) : 1\r\n(1, None, 65516, 0, 0, 0, 0, 0) : 104\r\n(1, None, 27, 0, 0, 0, 0, 0) : 1\r\n\r\nSo 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.\r\n\r\nscrolltest.py...\r\n\r\n#!/usr/bin/env python\r\n# -*- encoding: utf-8 -*-\r\nimport sys\r\nimport time\r\nimport termbox\r\n\r\neventdict = dict()\r\nwith termbox.Termbox() as tb:\r\n    finish = False\r\n    while finish==False:\r\n        event = tb.poll_event()\r\n        (type, ch, key, mod, w, h, x, y ) = event\r\n        if type==termbox.EVENT_KEY and ch=='X':\r\n            break\r\n        \r\n        if event in eventdict:\r\n            eventdict[event] += 1\r\n        else:\r\n            eventdict[event] = 1\r\n        time.sleep(0.01)\r\n        \r\nfor e in eventdict:\r\n    print e,\":\",eventdict[e]\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"dj-on-github"}}