so QB64 inkey$ requires multiple presses to register a key press
e.g. :
DO
IF inkey$ = "a" THEN GOTO 100
IF inkey$ = "s" THEN GOTO 200
IF inkey$ = "d" THEN GOTO 300
LOOP UNTIL inkey$ = "a" OR inkey$ = "s" OR inkey$ = "d"
100 PRINT "You pressed A."
200 PRINT "You pressed S."
300 PRINT "You pressed D."
how do I counter this bug?
QB64 inkey$ requires multiple presses
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Re: QB64 inkey$ requires multiple presses
Not a bug! You were reading the INKEY$ function many times and results were read and changed each time:
Since case is lower you do not need to check for both "d" and "D"
Code: Select all
DO
K$ = LCASE$(INKEY$) ' K holds first Inkey$ result and lowers uppercase types too
LOOP UNTIL K$ = "a" OR K$ = "s" OR K$ = "d"
IF K$ = "a" THEN PRINT "You pressed A."
IF K$ = "s" THEN PRINT "You pressed S."
IF K$ = "d" THEN PRINT "You pressed D."
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Re: QB64 inkey$ requires multiple presses
thank you really much!burger2227 wrote:Not a bug! You were reading the INKEY$ function many times and results were read and changed each time:Since case is lower you do not need to check for both "d" and "D"Code: Select all
DO K$ = LCASE$(INKEY$) ' K holds first Inkey$ result and lowers uppercase types too LOOP UNTIL K$ = "a" OR K$ = "s" OR K$ = "d" IF K$ = "a" THEN PRINT "You pressed A." IF K$ = "s" THEN PRINT "You pressed S." IF K$ = "d" THEN PRINT "You pressed D."
I would claim this best answer if I could
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Re: QB64 inkey$ requires multiple presses
That is why we are here !
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0