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

Chang Chi 21 Reputation points

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

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,593 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Guido Franzke 2,196 Reputation points

    you have already asked this question some days before:
    The answer there is correct.
    Regards, Guido

    0 comments No comments

  2. Sam of Simple Samples 5,516 Reputation points

    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