Portable getch() for Python.
More than a few times, I've had liked to just write getch() instead of
raw_input(). This is the missing cross-platform functionality you've been
looking for.
Install with pip:
$ pip install py-getchfrom getch import getch, pause
key = getch()
print('You pressed:', key)
pause()Wait for a keypress:
ch = getch()This works like you'd expect, except that it returns a string.
You can also pause with the standard 'Press any key to continue. . . ' message:
pause()Or pause with a custom message:
pause('Press any key to exit.')You can have Python exit automatically with:
from getch import pause_exit
pause_exit(status=0, message='Press any key to exit.')- Check the open issues or open a new issue to start a discussion around your feature idea or the bug you found
- Fork the repository, make your changes, and add yourself to Authors.md
- Send a pull request
If your PR has been waiting a while, feel free to ping me on Twitter.