How to detect the PAUSE/BREAK key?

General FreeBASIC programming questions.
Posts: 146
Joined: May 28, 2005 6:08
Location: Everywhere

How to detect the PAUSE/BREAK key?

Postby Nexinarus » Dec 17, 2008 4:17

I am trying to detect when the PAUSE/BREAK key is pushed so that my game will pause, however multikey() seems to not support the key... is it possible? Surely its not rocket science..
Posts: 778
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)

Postby Mysoft » Dec 17, 2008 10:29

This code work and explain using both multikey method and Windows Virtual Key... (that is for windows only :P)

so for the fbgfx method, you may want to use events...
and it will differ from the "num lock" key cuz the SC_NUMLOCK will be down for a very brief period of time even you keep the key pressed (that's why i recommend to use fb events for that... so then you can found if the key pressed is SC_NUMLOCK or PAUSE by the time it was down (so something like 30 or 50ms will be PAUSE more than that (will be SC_NUMLOCK)

i hope that it helps :P

also windows VK_PAUSE doesnt need that trick (since windows will deal with it for itself)

Code: Select all

#include ""
' *** for windows vk_key method ***
#include ""

screen 13
print "Press the pause key!"
while multikey(fb.SC_NUMLOCK) = 0
  sleep 1
print "Done.":sleep 500,1

print "Press it again! :P"
while (GetKeyState(VK_PAUSE) and 32768) = 0
  sleep 1
print "Done."
print "Any key to finish"

Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests