{"action":"created","issue":{"url":"https://api.github.com/repos/erikrose/blessings/issues/22","labels_url":"https://api.github.com/repos/erikrose/blessings/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/erikrose/blessings/issues/22/comments","events_url":"https://api.github.com/repos/erikrose/blessings/issues/22/events","html_url":"https://github.com/erikrose/blessings/issues/22","id":5996389,"number":22,"title":"Provide keyboard input","user":{"login":"erikrose","id":295816,"avatar_url":"https://avatars.githubusercontent.com/u/295816?v=3","gravatar_id":"","url":"https://api.github.com/users/erikrose","html_url":"https://github.com/erikrose","followers_url":"https://api.github.com/users/erikrose/followers","following_url":"https://api.github.com/users/erikrose/following{/other_user}","gists_url":"https://api.github.com/users/erikrose/gists{/gist_id}","starred_url":"https://api.github.com/users/erikrose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikrose/subscriptions","organizations_url":"https://api.github.com/users/erikrose/orgs","repos_url":"https://api.github.com/users/erikrose/repos","events_url":"https://api.github.com/users/erikrose/events{/privacy}","received_events_url":"https://api.github.com/users/erikrose/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/erikrose/blessings/labels/enhancement","name":"enhancement","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":28,"created_at":"2012-08-02T16:33:06Z","updated_at":"2015-04-08T00:18:22Z","closed_at":null,"body":"It's really freaking hard to read the state of the keyboard without calling ``curses.initscr().getch()``. Let's make it easier on people; I've had 2 requests about it. Here's one implementation, from http://love-python.blogspot.com/2010/03/getch-in-python-get-single-character.html:\n\n    import sys    \n    import termios\n    import fcntl\n    \n    def myGetch():\n        fd = sys.stdin.fileno()\n    \n        oldterm = termios.tcgetattr(fd)\n        newattr = termios.tcgetattr(fd)\n        newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO\n        termios.tcsetattr(fd, termios.TCSANOW, newattr)\n    \n        oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)\n        fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)\n    \n        try:        \n            while 1:            \n                try:\n                    c = sys.stdin.read(1)\n                    break\n                except IOError: pass\n        finally:\n            termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)\n            fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)\n\nAs you can deduce from the above, you can do it with echo or without, async or blocking (see curses docs for that latter bit)."},"comment":{"url":"https://api.github.com/repos/erikrose/blessings/issues/comments/90766656","html_url":"https://github.com/erikrose/blessings/issues/22#issuecomment-90766656","issue_url":"https://api.github.com/repos/erikrose/blessings/issues/22","id":90766656,"user":{"login":"jquast","id":972584,"avatar_url":"https://avatars.githubusercontent.com/u/972584?v=3","gravatar_id":"","url":"https://api.github.com/users/jquast","html_url":"https://github.com/jquast","followers_url":"https://api.github.com/users/jquast/followers","following_url":"https://api.github.com/users/jquast/following{/other_user}","gists_url":"https://api.github.com/users/jquast/gists{/gist_id}","starred_url":"https://api.github.com/users/jquast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jquast/subscriptions","organizations_url":"https://api.github.com/users/jquast/orgs","repos_url":"https://api.github.com/users/jquast/repos","events_url":"https://api.github.com/users/jquast/events{/privacy}","received_events_url":"https://api.github.com/users/jquast/received_events","type":"User","site_admin":false},"created_at":"2015-04-08T00:18:22Z","updated_at":"2015-04-08T00:18:22Z","body":"This is resolved in 'blessed-integration' branch."}}