0

hello everyone!
i'd like to know if theres a way to run my program until the user presses Esc button.
i use linux environment and my main function runs fork().i want the program to stop
the fork() when the user presses escape.
thank you!

3
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by WaltP
-1

You need some sort of event handling... Don't really know what libs are used under lin.

0

As I said, I don't really now those libraries, try googling something like "c++ checking if key is pressed", or adding linux in there.

0

yes i have searched but c++ doesnt support an event handling so i'm curious if even theres a way to stop a loop when a key is pressed without using instructions like cin as they have to wait for an input.thank you anyway

0

there must be a library.
And what I mean is, you run a loop (at limited FPS, not to kill the CPU) and in every loop you check if the key was pressed.
Good tutorial on that is at LazyFoo, but it uses a graphic library (SDL) which IMO would be an overkill here, but why not?

0

In Standard C++ there is not. ESC is not a magic key today*. Just use ENTER.


* It never really was. The use of ESC has always been non-portable and much more difficult to program.

Edited by WaltP: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.