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

Chang Chi 61 Reputation points
2021-03-01T22:21:00.123+00:00

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

Developer technologies | C++
{count} votes

2 answers

Sort by: Most helpful
  1. Guido Franzke 2,191 Reputation points
    2021-03-02T06:58:07.1+00:00

    Hello,
    you have already asked this question some days before:
    how-to-get-a-notice-when-a-up-aroow-key-is-pressed.html
    The answer there is correct.
    Regards, Guido

    0 comments No comments

  2. Sam of Simple Samples 5,546 Reputation points
    2021-03-03T19:39:53.913+00:00

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.