How I Check For Arrow Keys?

This is a discussion on How I Check For Arrow Keys? within the C Programming forums, part of the General Programming Boards category; how i check for arrow keys using standard io functions? (nothing of allegro)...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    14

    How I Check For Arrow Keys?

    how i check for arrow keys using standard io functions? (nothing of allegro)

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    What do you mean by "standard"? Each Operating System and Compiler on it might have it's own way of implementing such functions. But most of them support the 'getch()', a function for a requirement as yours.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    On my machine (Win98) using Bloodshed Dev compiler you have to include conio_mingw.h or similar instead of the normal conio.h, and the function is actually _getch();
    The values it returns for the arrow keys are 75, 76, 80, and 81 - I THINK, but test them yourself, and again - this is for the above platform, etc...

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    BTW: on my system - "getch()" does not work. That is, it would retrieve the char but would the function would not return till the carriage return was pressed! So after pouring over my headers I found the older, renamed "_getch()", which returned immediately..
    Code:
    #include <ip.hpp>

  5. #5
    Unregistered
    Guest
    Also, the key codes are different between OS's (I think)

    So just cuz it works for 98 doesn't mean it will work for 2000

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. ToUnicodeEx and dead keys inside system wide hooks
    By RevengerPT in forum Windows Programming
    Replies: 1
    Last Post: 08-13-2009, 02:51 PM
  3. Simulate Keys with a Keyboard Hook
    By guitarist809 in forum Windows Programming
    Replies: 3
    Last Post: 11-14-2008, 07:14 PM
  4. how to check input is decimal or not?
    By kalamram in forum C Programming
    Replies: 3
    Last Post: 08-31-2007, 07:07 PM
  5. Check application visibility
    By 3saul in forum Linux Programming
    Replies: 2
    Last Post: 02-13-2006, 04:13 PM

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