Can I catch some keys like ESC or ENTER, BACKSPACE,ARROWS etc.. whit cin>>? Or iostream? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 Answers
+ 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