Like this

by (Login burger2227)
R

 

DECLARE FUNCTION scankey% (scancode%)


CLS
tmp$ = " ## \\ "
' program or game code
DO
IF scankey%(1) THEN EXIT DO 'escape exit
row = 2 'display the key down states to show you how it works!
FOR x% = 1 TO 88 'read each key scancode from array
L = x% MOD 10: column = (7 * L) + 5
IF L = 0 THEN row = row + 2
LOCATE row, column
IF scankey%(x%) THEN PRINT USING tmp$; x%; STRING$(2, 219) ELSE PRINT USING tmp$; x%; "UP"
NEXT
LOOP
END

FUNCTION scankey% (scancode%)
STATIC Ready%, keyflags%()
IF NOT Ready% THEN REDIM keyflags%(0 TO 127): Ready% = -1 'the keyboard states
i% = INP(&H60)
IF (i% AND 128) THEN keyflags%(i% XOR 128) = 0
IF (i% AND 128) = 0 THEN keyflags%(i%) = -1
K$ = INKEY$ 'only clears keyboard buffer
scankey% = keyflags%(scancode%)
END FUNCTION

Posted on Sep 5, 2011, 3:04 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
Re: Like this on Sep 5
 The function uses INP to read the keyboard on Sep 5
  Re: The function uses INP to read the keyboard on Sep 6
  Tested the scancodes in my pong program... on Sep 6
   It works but CLS is killing it on Sep 6
    Re: It works but CLS is killing it on Sep 6
     The function works. The drawing doesn'tClippy on Sep 6
      Re: The function works. The drawing doesn't on Sep 6
       Try using _DISPLAY at bottom of loop too! on Sep 6
        Re: Try using _DISPLAY at bottom of loop too! on Sep 7
         Use the code I posted above. on Sep 8
          Re: Use the code I posted above. on Sep 8
           No wonder! It was trying to zero out the function array every loop on Sep 8
            It works! on Sep 10
             Apparently on Sep 11
              Re: Apparently on Sep 11
        Re: Try using _DISPLAY at bottom of loop too! on Sep 7
        Re: Try using _DISPLAY at bottom of loop too! on Sep 7
        I also have a problem with another program on Sep 7
         Re: I also have a problem with another program on Sep 11
          Re: I also have a problem with another program on Sep 11
           well... on Sep 11
            Re: well... on Sep 11

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement