How do I detect enter in C++?
I’m using Replit as the IDE, so it should work there.
How do I detect enter in C++?
I’m using Replit as the IDE, so it should work there.
I think it works the same as python, “”
Following this article, you can do it like so (cross platform):
#include <iostream>
#include <conio.h>
int main() {
char ch;
//program pauses here until key is pressed
ch = _getch();
if(ch == 'a')
std::cout << "Key Pressed: a" << std::endl;
if(ch == 's')
std::cout << "Key Pressed: s" << std::endl;
else if(ch == 'A')
std::cout << "Key Pressed: A" << std::endl;
return 0;
}
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.