Thread: How I Check For Arrow Keys?

  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,708
    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,708
    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 <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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, 08: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, 05:13 PM