Author Topic: GetAsyncKeyState()  (Read 3512 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
GetAsyncKeyState()
« on: September 13, 2006 »
I wonder if anyone knows how to make it so that when you press a key using GetAsyncKeyState() that it doesnt make things happen so quickly when a key is pressed?

Dummy example:

Code: [Select]
If (GetAsyncKeyState(68)) Then Debug=Debug+1
If Debug>1 Then Debug=0

If Debug Then
  'Display Info
End If

Cheers and many thanks,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: GetAsyncKeyState()
« Reply #1 on: September 14, 2006 »
Try this one it will work fine  ;)

Code: [Select]
If ( GetAsyncKeyState(68) = -32767 ) Then Debug=Debug+1
If Debug>1 Then Debug=0

If Debug Then
  'Display Info
End If
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: GetAsyncKeyState()
« Reply #2 on: September 14, 2006 »
Cheers for that buddy.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: GetAsyncKeyState()
« Reply #3 on: September 14, 2006 »
Because GetAsyncKeyState returns two values at once.  0x8000 if the key is currently pressed and/or 0x0001 if the key was pressed since the last time you called GetAsyncKeyState.  Rbraz's -32767 is, in fact, 0x8001 (&h8001 in basic).

Jim
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: GetAsyncKeyState()
« Reply #4 on: September 14, 2006 »
This function is very useful, I was messing with it yesterday and came on to post the very same question you did Clyde so I guess I got the fastest answer ever. :)
Shockwave ^ Codigos
Challenge Trophies Won: