ascii value for the arrow keys

This is a discussion on ascii value for the arrow keys within the C++ Programming forums, part of the General Programming Boards category; what would the ascii value for the up and down arrow keys? What I have so far. I have a ...

  1. #1
    uvacow
    Guest

    ascii value for the arrow keys

    what would the ascii value for the up and down arrow keys? What I have so far.

    I have a counter. I want the arrow keys (up and down) to allow you increment or decrement the counter. I would use a switch statement to get this, but i need to know how to distingush the 2 keys. right now if i read them in as ints, i get -32 for both... Any suggestions?

    cow

  2. #2
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    ummm in dos...

    Im not sure if you can use the arrow keys in dos but hey i dont know
    +++
    ++
    + Sekti
    ++
    +++

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    zMan

    Find out with the code below what values the keys return
    my system returns something like
    72,75,80 and something else....
    Most keys place only one value in the buffer... the arrow keys however place 2 224, ? depending on which arrow key was pressed. That is why I test for the value 224. Your system may or may not place that value there....



    Code:
    #include<iostream.h>
    #include<conio.h>
    
    void main(void)
    {
    	
            while(1)
            {
                  while(!kbhit());
                  int i = getch();
    		
                  if( i == '0')
    	    break;
    
                if( i == 224 ) //whenever an arrow key is pressse my
     	 i = getch(); //system returns 224 prior to the key val
    
                cout << "You pressed key number: " << i << endl;
        }
    
    }
    zMan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 02:27 AM
  2. Do arrow keys have two ascii values
    By vaibhav in forum C++ Programming
    Replies: 4
    Last Post: 01-16-2006, 07:03 AM
  3. ascii values for keys
    By acid45 in forum C Programming
    Replies: 2
    Last Post: 05-12-2003, 07:13 AM
  4. Ascii code for arrow keys
    By beginner in forum C Programming
    Replies: 1
    Last Post: 11-07-2002, 12:29 PM
  5. Arrow keys
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 03-27-2002, 10:49 AM

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