using function keys

This is a discussion on using function keys within the C++ Programming forums, part of the General Programming Boards category; I was wondering on how to implement function keys (F1, F2) into a menu selection. At the moment, i'm using ...

  1. #1
    Deleted Account
    Join Date
    Mar 2005
    Posts
    57

    using function keys

    I was wondering on how to implement function keys (F1, F2) into a menu selection. At the moment, i'm using case to select between different options (a, b, c etc). I want to be able to make use of F1 and so on as well......This is my first time in c++ programming, so could u please make it as simple as possible....thanks

  2. #2
    Banned
    Join Date
    Oct 2004
    Posts
    250
    What do you mean? a hotkey?
    if so you could use something like
    Code:
    if(GetAsyncKeyState(VK_F1))

  3. #3
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    note for that you need the windows.h header

  4. #4
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    If your OS is Windows then sure, you can use GetAsyncKeyState.
    Quote Originally Posted by cgod
    What do you mean? a hotkey?
    if so you could use something like
    Code:
    if(GetAsyncKeyState(VK_F1))
    Pay attention cgod!
    MSDN:
    Code:
    SHORT GetAsyncKeyState(
      int vKey   // virtual-key code
    );
    Return Values
    If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState

    So test for F1 should be:
    Code:
    if (GetAsyncKeyState ( VK_F1 ) & SHRT_MAX)
    See
    http://faq.cprogramming.com/cgi-bin/...&id=1043284392
    for example!
    Last edited by Micko; 03-19-2005 at 05:21 PM.
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM

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