Arrow key reading

This is a discussion on Arrow key reading within the C++ Programming forums, part of the General Programming Boards category; How may I get my program to recognise the arrow keys? I can get ESC key recognised with 27, but ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    26

    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
    Location
    The edge of the known universe
    Posts
    32,825
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

  4. #4
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    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
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,701

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    24
    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:

    Code:
    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, 03: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, 04:39 AM
  4. Arrow Key menus in console mode
    By Ion Blade in forum C++ Programming
    Replies: 8
    Last Post: 05-31-2002, 02:09 PM
  5. Registery with api?
    By ismael86 in forum Windows Programming
    Replies: 1
    Last Post: 05-14-2002, 11:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21