03-12-2004, 08:19 PM
Suppose I am using a keyboard handler. When the keyboard handler is on, you can't use QB's INKEY$ function. The handler allows for swift keystroke detection, but what if you want to use both styles, one that constantly checks the status of a key press using the handler, and one like INKEY$, where you want a routine to execute once the key is released after pressing it. Here's a routine you can use to do thatIt uses RELKEY from rellib, but that can be changed to any sort of kb handler. SKey stands for SlowKey)
...where Flag% is a variable that is passed back to you givingyou the status, KeyCode% is a flag variable used if you have more than one key you want this sub to work on(an ID variable for the key), and Scancode% is the scancode of the key.
All you need is a flag variable for the key you want. If you want many different keys, set up a TYPE, like so:
Here's how you would use the subroutine:
So this routine allows the keyboard handler to be on, and still have the ability to execute code with full keypresses. I thought I might share this with you. :wink:
Code:
SUB SKey (Flag%, KeyCode%, ScanCode%)
Flag% = 0
IF KeyCode% = -1 AND RelKey(ScanCode%) = 0 THEN KeyCode% = 0
IF RelKey(ScanCode%) AND KeyCode% = 0 THEN
KeyCode% = -1
Flag% = -1
END IF
END SUB
...where Flag% is a variable that is passed back to you givingyou the status, KeyCode% is a flag variable used if you have more than one key you want this sub to work on(an ID variable for the key), and Scancode% is the scancode of the key.
All you need is a flag variable for the key you want. If you want many different keys, set up a TYPE, like so:
Code:
TYPE SlowKeysType
EnterKey as integer
EscKey as integer
SPaceKey as integer
END TYPE
DIM SHARED SlowKeys AS SlowKeysType
Here's how you would use the subroutine:
Code:
SKey Flag%, SlowKey.CtrlKey, &H1D
IF Flag% = -1 THEN Execute Code
So this routine allows the keyboard handler to be on, and still have the ability to execute code with full keypresses. I thought I might share this with you. :wink:
strosmash :
www.geocities.com/juice801980/astro.zip
T.A.N.K :
www.geocities.com/juice801980/tank.zip
(right click, save-as...)
www.geocities.com/juice801980/astro.zip
T.A.N.K :
www.geocities.com/juice801980/tank.zip
(right click, save-as...)