+ 8

How to get only a single character as input without pressing enter ?

i am planning to get the inputs as a single character as it is being typed. I want to receive it without pressing enter . Any help available? Thanks in advance 😊

15th Feb 2017, 1:22 AM
SANJAY SIDDHARTH C V
SANJAY SIDDHARTH C V - avatar
8 Respuestas
+ 17
Unfortunately, module curses is not available in Sololearn. They really need to fix the Code Playground, starting with the input system.
16th Feb 2017, 6:31 PM
Gami
Gami - avatar
+ 8
Something like this: I haven't ever really used this before so I found this question interesting and looked it up in the python docs. Note this is for python 3.5, but I didn't see much difference for other versions. https://docs.python.org/3.5/library/curses.html https://docs.python.org/3.5/library/curses.html#window-objects import curses screen = curses.initscr() curses.cbreak() screen.keypad(1) screen.addstr("Enter q to quit ") screen.refresh() key = '' while key != ord('q'): key = screen.getch() screen.addch(key) screen.refresh() curses.endwin()
15th Feb 2017, 5:26 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
I love that's app Thanks u very match
16th Feb 2017, 10:50 PM
wadkrar
+ 1
if you are using c language or c++ you can use a loop and condition along with the _kbhit () and _getch () functions. while (_khbit) { _getch(); } but this code is useless. you need to implement an idea. The kbhit is to tell the computer a key has been hit. the getch gets the key that was hit without prompt.
16th Feb 2017, 8:49 PM
Ahmed Magaji
Ahmed Magaji - avatar
0
Thanks... I'll try this code and ping you if any queries arises
16th Feb 2017, 2:52 AM
SANJAY SIDDHARTH C V
SANJAY SIDDHARTH C V - avatar
0
;)
16th Feb 2017, 8:21 PM
CodePython
CodePython - avatar
0
I love that's app Thanks u very match
16th Feb 2017, 10:50 PM
wadkrar
- 1
i love this app
15th Feb 2017, 12:09 PM
rahman ART
rahman ART - avatar