How to know which key is presses from keyboard in python. Like c cpp has getch(). | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to know which key is presses from keyboard in python. Like c cpp has getch().

Python has getkey, keyboard etc many such libraries but all work on terminal. Any library which is present in sololearn. Or any other method to get the pressed key.

28th May 2020, 12:39 PM
Jyoti Rani
Jyoti Rani - avatar
6 Answers
+ 2
pycharm does not 'have' libraries, apart from the standard one. You have to pip install them from a repository.
28th May 2020, 1:55 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
Code Playground for Python is not interactive, it won't read keys during runtime.
28th May 2020, 1:02 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
I guess pycharm does not have keyboard library
28th May 2020, 1:20 PM
Jyoti Rani
Jyoti Rani - avatar
+ 1
You can use "listen()" It will tell to listen whick key is pressed and can call the function
6th Jun 2020, 7:27 PM
Faisal Shaikh
0
Kuba Siekierzyński any method to do this in pycharm?
28th May 2020, 1:13 PM
Jyoti Rani
Jyoti Rani - avatar
0
There's an excellent module named... keyboard, for just that :)
28th May 2020, 1:18 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar