Thread: ASCII Codes

  1. #1
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question ASCII Codes

    Does anyone know the ASCII Codes for the arrow keys? If it helps i'm using Borland on a Windows O/S, in console mode.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    My best code is written with the delete key.

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    It is as follows


    up arrow 0x48
    down arrow 0x50
    left arrow 0x4b
    right arrow 0x4d

  4. #4
    Registered User Liam Battle's Avatar
    Join Date
    Jan 2002
    Posts
    114
    UP_KEY 1072
    DOWN_KEY 1080
    LEFT_KEY 1075
    RIGHT_KEY 1077

    Those are the key numbers you are looking for in borland
    LB0: * Life once school is done
    LB1: N <- WakeUp;
    LB2: N <- C++_Code;
    LB3: N >= Tired : N <- Sleep;
    LB4: JMP*-3;

  5. #5
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question Question:

    It doesn't sense the grey keys... What do I have to do?

  6. #6
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Grey keys? I assume you mean the numpad..
    I believe they're 100, 102, 104 and 106... I'm not sure in which order though.

  7. #7
    Seņor Member
    Join Date
    Jan 2002
    Posts
    560
    Code:
    #include  <iostream.h>
    #include <conio.h>
    int main()
    {
       char a = getch();
       //press one of the arrow keys
       cout << "The ASCII value for the button you pressed is " << int(a);
       return 0;
    }

  8. #8
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Main?

    What about the main arrow keys?

  9. #9
    Seņor Member
    Join Date
    Jan 2002
    Posts
    560
    Look at the program I just wrote. You can get the ASCII of any button. Just compile it.

  10. #10
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Nope

    It doesn't show it for the arrow keys next to the main part of the keyboard... The ones that don't use the num keys... any body?

  11. #11
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question Hello?

    Noone's responded in a while... Help!!!???
    I Repeat question yes???

    It doesn't show it for the arrow keys next to the main part of the keyboard... The ones that don't use the num keys... any body?

    or

    Does anyone know the code for the main arrow keys?

  12. #12
    Registered User
    Join Date
    Feb 2002
    Posts
    19
    Here is what I use.
    However Im using MSVC++ although it should still work for you.

    Code:
    #include <iostream.h>
    #include <conio.h> // for _kbhit and getch()
    
    int main()
    {
    	char key;
    	int iKey;
    	bool endprog = false;
    
    	do
    	{
    		if(_kbhit())//if a key is in the buffer
    		{
    			key = getch();//then get the key
    			iKey = key;
    
    			cout<<"key: "<<key<<" iKey: "<<iKey<<endl;
    
    			if(key == 'Q' || key == 'q')
    				endprog = true;
    		}
    
    	}while(!endprog);
    
    	return 0;
    }
    note that when you press a function key, arrow key, or any other special key it will display twice because all of the non alphabetic keys send two hits to the input buffer.

    Also you might want to check your Borland documentation for allready defined constants. For example in MSVC++ the enter key is VK_RETURN.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about ASCII codes
    By rwmarsh in forum C++ Programming
    Replies: 4
    Last Post: 04-17-2006, 10:49 AM
  2. ASCII Codes
    By X PaYnE X in forum Windows Programming
    Replies: 1
    Last Post: 12-31-2003, 01:37 PM
  3. Getting ASCII codes
    By moonwalker in forum C Programming
    Replies: 3
    Last Post: 07-24-2002, 01:17 PM
  4. ascii codes!!
    By condorx in forum C Programming
    Replies: 23
    Last Post: 04-30-2002, 08:10 PM
  5. converting scan codes to ascii codes
    By stupid_mutt in forum C Programming
    Replies: 11
    Last Post: 01-25-2002, 04:06 PM