Arrow keys

This is a discussion on Arrow keys within the C Programming forums, part of the General Programming Boards category; Hi, I found out a method of detecting arrow keys in one thread i found. It's that after getting the ...

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Arrow keys

    Hi,

    I found out a method of detecting arrow keys in one thread i found. It's that after getting the ascii value from arrow keys of 224, there is another value in the buffer, so all i havta do is run getch() again and i'll get the different values for different arrow keys.

    But i read in some threads that:

    left arrow = 'K'
    up arrow = 'H'
    down arrow = 'P'
    right arrow = 'M'

    Whys that? It doesn't even work for me.

    thnx

  2. #2
    Unregistered
    Guest
    These K, H, P and M are scan codes of the arrow keys, getch () gives a scan code. These codes work for most keyboards and not for all (scan codes depend on keyboard), but this is the sipmplest possibility to get console input without having to press ENTER. The other possibility is to use Windows API function, but getch () is certainly much easier to use for newbies..

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    Is there an ANSII-conform way to get return-codes without having to press carriage-return (Enter)?

    klausi
    When I close my eyes nobody can see me...

  4. #4
    Unregistered
    Guest
    Probably not, ANSI c seems to be a standard from the time when monitors wrote one line in a second.

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Is there an ANSII-conform way to get return-codes without having to press carriage-return
    No

    -Prelude
    My best code is written with the delete key.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    Thanks, I thought to have heard that it would exit.

    klausi
    When I close my eyes nobody can see me...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Movement with arrow keys
    By louis_mine in forum C Programming
    Replies: 3
    Last Post: 02-06-2005, 04:35 PM
  2. Interfacing with arrow keys...
    By adityakarnad in forum Game Programming
    Replies: 1
    Last Post: 08-30-2003, 11:25 PM
  3. Ascii code for arrow keys
    By beginner in forum C Programming
    Replies: 1
    Last Post: 11-07-2002, 01:29 PM
  4. Arrow keys!
    By Paninaro in forum C Programming
    Replies: 8
    Last Post: 06-26-2002, 08:39 PM
  5. msdos arrow keys?
    By seditee in forum Game Programming
    Replies: 3
    Last Post: 05-08-2002, 12:29 AM

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