c++ how to detect Enter button input
i have been trying to detect enter button and arrow keys and failing realy hard if some one could give me a source to detect arrow and enter key i would be realy greatful
There is no C++ way to do this. The language does not assume it is compiling programs for use on a device with a keyboard.
Such things are handled via libraries for the operating system you are running on.
However, if you mean in a console app, many compilers ship with a nonstandard header called conio.h or similar which provides something like kbhit(). It really depends on the context you need.
Such things are handled via libraries for the operating system you are running on.
However, if you mean in a console app, many compilers ship with a nonstandard header called conio.h or similar which provides something like kbhit(). It really depends on the context you need.
Since you are on windows try looking at using the windows.h file and google GetAsyncKeyState should be all you need to figure it out.
For console apps look up stdio.h, iostream, and friends.
For windowed apps, look up GetAsyncKeyState and WM_KEYDOWN/WM_KEYUP.
You probably want to abstract windowed mode input anyway as it a bit of a minefield to do properly. Search this forum for tons of advice using those keywords above...
Good luck!
Which API are you using? Did you succeed in getting SFML working?
By "button" do you mean a button widget in a window that the player clicks on with a mouse, or do you mean a keyboard key, or do you mean the left or right mouse buttons?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement