Detect if i key is held on..

This is a discussion on Detect if i key is held on.. within the Game Programming forums, part of the General Programming Boards category; Hi, How can i know if the user is holding onto a particular key? THis is important in many games ...

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Detect if i key is held on..

    Hi,

    How can i know if the user is holding onto a particular key? THis is important in many games i know.

    thnx

  2. #2
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    You have to modify your keyboard handler, or write another one.
    Yoshi

  3. #3
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    I don't know what a keyboard handler is, and where it is located, and how to modify it.

    Is there any other way though?

  4. #4
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    i have used the bioskey() function to detect which key was pressed.

    though it may be compiler/os specific and is maybe outdated.

    its in bios.h in my compiler

  5. #5
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    I don't have bios.h

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Are you writing this in the console or an actual Win32 application?? This would probably help people understand a little more and your problem.

  7. #7
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    Console, on winxp pro.

  8. #8
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    would getch work?

    im not sure, ask someone else here but getch may work, unless its an overly complex game or something

  9. #9
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    Hi,

    I didn't mean just a key press, i want to know if the user kept holding onto the key...

  10. #10
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    For DevC++ it would be kbhit() to see when a single key is being press, but I have no idea about when a key is being hold down on. You could do a search on it here and see if any results come up.

  11. #11
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    Try GetAsyncKeyState() (windows API function).
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM

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