Reputation: 121
I have a Python-3 application that has an interactive command-line interface. Now I would like to add non-canonical keyboard input functionality to this application. I would like it to behave much like how Python interpreter handles its keyboard inputs - for example, keys like up-arrow and down-arrow could scroll command histories and other control keys could move the cursor to beginning/end of line, etc.
I had a cursory glance of getkey and keyboard modules, but what is the best (and easiest) Python 3 module that I could use for this feature?
Upvotes: 0
Views: 209
Reputation: 142631
There are special modules to create interactive command line
.
They can use special keys to show history, edit line, auto suggestions.
There is standard module cmd which should have this functionality.
See also extended cmd2
Probably the most popular is Python Prompt Toolkit. Probably even IPython
uses it.
See Gallery, basic tutorila and examples with PtPython
Probably most of them use standard modul readline - so maybe you will need this for your project.
Other
BTW: 4 Python libraries for building great command-line user interfaces
Upvotes: 2