Thread: msdos arrow keys?

  1. #1
    Registered User seditee's Avatar
    Join Date
    Apr 2002
    Posts
    82

    Question msdos arrow keys?

    question: how do i get the arrow keys instead of these shift, alt, and control keys working? i.e. left arrow, right arrow, up arrow, down arrow. help. s.o.s.


    Code:
    
    
    
    
    keyboard=*(unsigned short far*)MK_FP(0x40,0x17);
    
    if(kbhit()){a=getch();}
    
    if(keyboard&0x0002)       
      {              
        // action.
      }
    
    if(keyboard&0x0001)                      
      {
        // action.
      }
    
    if(keyboard&0x0004)
      {
        // action.
      }
    	
    if(keyboard&0x0008)                     
      {
        // action.
      }




    Last edited by seditee; 05-07-2002 at 01:33 AM.
    lebios

  2. #2
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Here is what I did for my maze game that used arrow keys:

    Code:
    		 		
    		if(kbhit())			//if a key is pressed
    		{		            
    			key = getch();	//get the key
    			key_2 = getch();
    			move = (char)key_2; //change it to an int		
    			
    		}
    This below is what you want to do if a certain key is pressed:

    Code:
              if(move == 77)
                 {
                   //do stuff
                 }
    left = 75
    right = 77
    up = 72
    down = 80

    Those are the values for each of the keys.

    Also, this site has a lot of good info on ASCII values.

    EDIT: took out some code that was ony relevant to my program
    Last edited by TechWins; 05-07-2002 at 11:59 AM.

  3. #3
    Registered User seditee's Avatar
    Join Date
    Apr 2002
    Posts
    82

    Cool

    that's a neat little maze game you made there.
    lebios

  4. #4
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Thanks.

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, 10: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, 07:39 PM
  5. Arrow keys
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 03-27-2002, 11:49 AM