Direction Keys

This is a discussion on Direction Keys within the C Programming forums, part of the General Programming Boards category; hi i am looking for a solutıon i wanna find ASCII codes for some keys: direction keys when i try ...

  1. #1
    esler
    Guest

    Question Direction Keys

    hi
    i am looking for a solutıon
    i wanna find ASCII codes for some keys:
    direction keys
    when i try to find it
    it gives me
    -32,80 for upper direction

    ı cant understand
    where can ı fınd ASCII codes for these keys

  2. #2
    Ethereal Raccoon Procyon's Avatar
    Join Date
    Aug 2001
    Posts
    189
    Input from the arrow keys will place their scan codes in the buffer (in DOS, at least.) You can then retrieve these scan codes with getch() and related functions. The scan codes are:

    Up: 80
    Down: 72
    Left: 75
    Right: 77

    Example:
    Code:
    int x = 0;
    int y = 0;
    char scancode;
    if (kbhit())
    {
      scancode = getch();
      if (scancode == 72) y--;
      if (scancode == 80) y++; 
      if (scancode == 72) x--;
      if (scancode == 75) x++;
    }
    
    printf("x = %d, y = %d), x, y);

  3. #3
    esler
    Guest

    Unhappy are you sure

    hi
    are you sure
    when ı trıed to wrıte
    alt+80 , ı got 'P'

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simulate Keys with a Keyboard Hook
    By guitarist809 in forum Windows Programming
    Replies: 3
    Last Post: 11-14-2008, 08:14 PM
  2. Mouse Maze Problem
    By Furbiesandbeans in forum C++ Programming
    Replies: 13
    Last Post: 04-28-2008, 05:20 PM
  3. blocking or passing keys with global hook
    By pmouse in forum Windows Programming
    Replies: 4
    Last Post: 08-29-2007, 03:54 PM
  4. Ascii code for direction keys
    By Whizza in forum C++ Programming
    Replies: 3
    Last Post: 05-24-2006, 05:45 AM
  5. Classic problem doesn't accept direction
    By cheesehead in forum C++ Programming
    Replies: 5
    Last Post: 11-13-2001, 06:32 PM

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