Thread: Arrow key reading

  1. #1
    Registered User
    Join Date
    Mar 2005

    Arrow key reading

    How may I get my program to recognise the arrow keys? I can get ESC key recognised with 27, but there is no ascii number for the arrow keys as I am aware. But there's surely another way to do it.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Which OS and Compiler?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Windows ME -- bloodshed Dev c++

  4. #4
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Manassas, VA USA
    I think the arrow keys return a scan code. The scan code for the two most popular types of keyboards are:

    up arrow: 75h or 48h
    left arrow: 6Bh or 4Bh
    down arrow: 72h or 50h
    right arrow: 74h or 4Dh
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  5. #5

  6. #6
    Registered User
    Join Date
    Jan 2005
    Well this is what I do to find out ascii code of key I wanna know. I use debug window of borland c++ 4.0 with this:

    int key = getch();
    Then i use the debug window and look at the value of key for the ascii number. Always worked so far for me so, for '0' it's 48 on my pc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arrow key codes
    By Overlord in forum C++ Programming
    Replies: 1
    Last Post: 09-02-2006, 02:36 AM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  4. Arrow Key menus in console mode
    By Ion Blade in forum C++ Programming
    Replies: 8
    Last Post: 05-31-2002, 01:09 PM
  5. Registery with api?
    By ismael86 in forum Windows Programming
    Replies: 1
    Last Post: 05-14-2002, 10:28 AM