Can I catch some keys like ESC or ENTER, BACKSPACE,ARROWS etc.. whit cin>>? Or iostream? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 4

Can I catch some keys like ESC or ENTER, BACKSPACE,ARROWS etc.. whit cin>>? Or iostream?

12th Mar 2017, 11:29 PM
AZTECCO
AZTECCO - avatar
5 Réponses
+ 15
I had a thread to query the use of arrow keys in C++ console app. I have been using getch() (C standard) till someone suggested getchar() (C++ standard).
12th Mar 2017, 11:37 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Thank you guys! Does those getXX() functions belongs to iostream or do i need to include some different headers?
13th Mar 2017, 8:09 AM
AZTECCO
AZTECCO - avatar
+ 4
ok. so much appreciated :)
13th Mar 2017, 8:15 AM
AZTECCO
AZTECCO - avatar
+ 1
Following two functions shall be best for capturing above keystrokes 1. getch() : Key will be captured but not displayed on the console. 2. getche() : Key will be captured and displayed on the console
13th Mar 2017, 6:18 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
0
getch() and getche () belong to conio.h whereas getchar () belongs to iostream.h
13th Mar 2017, 8:12 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar