That won't work, because INKEY$ does not returning CHR$(32) even though the space bar...

by Pete (Login The-Universe)
Admin

 

...is being held down.

SCREEN 0
DO
kb$ = INKEY$
IF kb$ = CHR$(32) THEN PRINT "-----------------" ELSE PRINT kb$; "..."
LOOP

Run it and you will see even though the key is held down, INKEY$ will register null for a few loops.

To get it to act with the space bar held or released would take an INP(96) routine or something like the following. Note that the delays will fail at midnight for a brief second, but the proper midnight delay could be used to prevent that. Also, I'm not 100% sure it is timed for all systems; it just works flawlessly as coded on my XP.

SCREEN 0
DO
z1 = TIMER
DO
kb$ = INKEY$
IF kb$ = CHR$(27) THEN SYSTEM
IF kb$ = CHR$(32) THEN
z1 = TIMER: DO: IF ABS(z1 - TIMER) > .2 THEN EXIT DO
LOOP
END IF
IF ABS(z1 - TIMER) > .1 OR kb$ = CHR$(32) THEN EXIT DO
LOOP
DEF SEG = 0: POKE 1052, PEEK(1050): DEF SEG
IF kb$ = CHR$(32) THEN PRINT "Space Bar is being held down" ELSE PRINT kb$; "..."
LOOP


-------------------

Pete



    
This message has been edited by The-Universe on Mar 5, 2010 4:46 PM

Posted on Mar 5, 2010, 4:26 PM

Respond to this message   

Return to Index

Response TitleAuthor and Date
Re: That won't work, because INKEY$ does not returning CHR$(32) even though the space bar...Anonymous on Mar 6
" "Lisztfr on Mar 6
 OkLisztfr on Mar 6
  Using INKEY$ and CVIMarineDon on Mar 6
   * Pete and I never indent.Sally Ninny on Mar 6
    Why not?Ben on Mar 6
     It is faster to code without indenting and lucky for me, I don't get confused.Pete on Mar 6

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