Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I easily use more that one key at a time?

I/O

Can I easily use more that one key at a time?

by  qbasicking  Posted    (Edited  )
This routine is flawless, it does not stick, it does not pause when switching buttons, and it doesn't pause before repeating, like so many multikey routinges do.


DECLARE SUB offkb ()
DECLARE SUB onkb ()
DECLARE SUB readassembly ()
REDIM kbcontrol%(128), kbmatrix%(128)
readassembly
onkb
DO
CLS
LOCATE 1
FOR a% = 0 TO 128
IF kbmatrix%(a%) THEN PRINT a% '<- tells you which key(s) are being pressed
IF kbmatrix%(1) THEN offkb: END '<- Press Esc to leave
NEXT
LOOP

kbdata:
DATA &HE9,&H1D,&H00,&HE9,&H3C,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00
DATA &H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00
DATA &H00,&H00,&H00,&H00,&H1E,&H31,&HC0,&H8E,&HD8,&HBE,&H24,&H00,&H0E,&H07
DATA &HBF,&H14,&H00,&HFC,&HA5,&HA5,&H8C,&HC3,&H8E,&HC0,&HBF,&H24,&H00,&HB8
DATA &H56,&H00,&HFA,&HAB,&H89,&HD8,&HAB,&HFB,&H1F,&HCB,&H1E,&H31,&HC0,&H8E
DATA &HC0,&HBF,&H24,&H00,&HBE,&H14,&H00,&H0E,&H1F,&HFC,&HFA,&HA5,&HA5,&HFB
DATA &H1F,&HCB,&HFB,&H9C,&H50,&H53,&H51,&H52,&H1E,&H56,&H06,&H57,&HE4,&H60
DATA &HB4,&H01,&HA8,&H80,&H74,&H04,&HB4,&H00,&H24,&H7F,&HD0,&HE0,&H88,&HC3
DATA &HB7,&H00,&HB0,&H00,&H2E,&H03,&H1E,&H12,&H00,&H2E,&H8E,&H1E,&H10,&H00
DATA &H86,&HE0,&H89,&H07,&HE4,&H61,&H0C,&H82,&HE6,&H61,&H24,&H7F,&HE6,&H61
DATA &HB0,&H20,&HE6,&H20,&H5F,&H07,&H5E,&H1F,&H5A,&H59,&H5B,&H58,&H9D,&HCF,-1

SUB offkb
SHARED keyboardonflag%, kbcontrol%()
IF (keyboardonflag% = 0) THEN EXIT SUB
keyboardonflag% = 0
DEF SEG = VARSEG(kbcontrol%(0))
CALL Absolute(3)
DEF SEG
END SUB

SUB onkb
SHARED kbcontrol%(), keyboardonflag%
IF keyboardonflag% THEN EXIT SUB
keyboardonflag% = 1
DEF SEG = VARSEG(kbcontrol%(0))
CALL Absolute(0)
DEF SEG
END SUB

SUB readassembly
SHARED kbcontrol%(), kbmatrix%()
RESTORE kbdata
DEF SEG = VARSEG(kbcontrol%(0))
I& = 0
GOTO skip0
DO
POKE I&, q%
I& = I& + 1
skip0:
READ q%
LOOP WHILE q% > -1
I& = 16
n& = VARSEG(kbmatrix%(0))
l& = n& AND 255
h& = ((n& AND &HFF00) \ 256)
POKE I&, l&
POKE I& + 1, h&
I& = I& + 2
n& = VARPTR(kbmatrix%(0))
l& = n& AND 255
h& = ((n& AND &HFF00) \ 256)
POKE I&, l&
POKE I& + 1, h&
I& = I& + 2
DEF SEG
END SUB

This routine has been used in a numerous GUIs, games, demos...
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top