Thread: F1 Key input

  1. #1
    Kebab Monster
    Guest

    F1 Key input

    does any1 know how to get the prog to recognise F1 as an input button to so i can link in a help interface

    cheers

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    Yes, it is very simple:
    PHP Code:
    //Inside the message switch in the main window loop
    case WM_KEYDOWN:
        switch(
    wParam){
               case 
    VK_F1:
                      
    //Do whatever
                
    break;
         }
    break; 
    One downside to this simple approach is that it will repeat the process every few milliseconds you hold the F1 key down. To correct that make a bool variable called F1pressed or something and set it to true at the end of the VK_F1 case statement, then code a WM_KEYUP the same as above just make it so it sets the bool variable to FALSE. Then set up an if statement around your help code to check if the bool variable is TRUE or not. I hope you get this!

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    3
    What library do i need to include for WM_KEYDOWN, wParam and VK_F1?

    cheers
    Last edited by Kebab Monster; 03-19-2002 at 04:00 AM.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    That code is for Windows only.

    If you wish to do this in DOS, you will need to write and INT 9 handler. Then you only need to check for the correct scan code for the F1 key (find a scan code table for the keyboard).

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    3
    Thnx mate

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I would love some input on my BST tree.
    By StevenGarcia in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2007, 01:22 AM
  2. User Input - Key 'Bouncing' = Bad
    By Tonto in forum Windows Programming
    Replies: 1
    Last Post: 12-09-2006, 09:37 AM
  3. Trouble with a lab
    By michael- in forum C Programming
    Replies: 18
    Last Post: 12-06-2005, 11:28 PM
  4. Key input?
    By Kavity in forum Linux Programming
    Replies: 0
    Last Post: 12-20-2002, 11:01 AM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 10:45 PM