question

ChangChi-2392 avatar image
0 Votes"
ChangChi-2392 asked ·

How to get a notice when a up arrow key is pressed in C language

Hi, I like to move a picture on the screen by clicking up, down, right, left arrow on the key board. Is there a way to get a notice in my software when “up arrow key” in keyboard is pressed, as an example. I tried bres=IsInputKey(0); How do I find out what key number is “up-arrow” Is this a right approach, I wonder. I use C, and C++ Languages on the platform of Windows10 and Visual studio 2017 Thank you in advance ChangChiTheGraphics

c++
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Same question as : how-to-get-a-notice-when-a-up-aroow-key-is-pressed.html
And you did not say if it is Win32, MFC, Winforms, ...


0 Votes 0 ·
GuidoFranzke avatar image
0 Votes"
GuidoFranzke answered ·

Hello,
you have already asked this question some days before:
[how-to-get-a-notice-when-a-up-aroow-key-is-pressed.html][1]
The answer there is correct.
Regards, Guido
[1]: https://docs.microsoft.com/en-us/answers/questions/287575/how-to-get-a-notice-when-a-up-aroow-key-is-pressed.html

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SimpleSamples avatar image
0 Votes"
SimpleSamples answered ·

You still have not said what type of project it is but since you say C (not C++) the implication is that it is a console program. See Reading Input Buffer Events - Windows Console. Try the sample program. There is much to learn but you can develop a relatively sophisticated text-mode UI Using the Console. That sample uses the KeyEventProc. In that when the arrow-up key is pressed ker.dwControlKeyState will be ENHANCED_KEY and ker.uChar.AsciiChar will be VK_UP.






·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.