CPCWiki forum

General Category => Programming => Topic started by: the777 on 10:17, 02 September 25

Title: is there a way of scanning 2 keys pressed at the same time from basic?
Post by: the777 on 10:17, 02 September 25
maybe with a few peeks? ive had a look on google and they all seem to be machine code routines
Title: Re: is there a way of scanning 2 keys pressed at the same time from basic?
Post by: pelrun on 12:05, 02 September 25
Use INKEY() (not INKEY$) to check whether a specific key is pressed or not; you can use it multiple times to check as many keys as you like.

https://www.cpcwiki.eu/index.php/Locomotive_BASIC#INKEY_.28.3Cinteger_expression.3E.29
Title: Re: is there a way of scanning 2 keys pressed at the same time from basic?
Post by: Jean-Marie on 12:09, 02 September 25
10 IF INKEY(58)+INKEY(50)=0 THEN 30
20 GOTO 10
30 PRINT"E and R keys have been pressed."
40 CALL &BB03

Title: Re: is there a way of scanning 2 keys pressed at the same time from basic?
Post by: andycadley on 14:15, 02 September 25
Remember that once you get to three or more keys, there are some combinations that will generate false results. 
Title: Re: is there a way of scanning 2 keys pressed at the same time from basic?
Post by: ZorrO on 15:38, 02 September 25
10 DEFINT a-z:' You can load screen here

20 IF INKEY(1)=0THEN t=t+1ELSE IF INKEY(8 )=0THEN t=t-1
30 IF INKEY(0)=0THEN t=t-40ELSE IF INKEY(2)=0THEN t=t+40
40 t=(t+1024)MOD 1024:v=48+t\256:w=t MOD 256:OUT&BC00,13:OUT&BD00,w:CALL&BD19:OUT&BC00,12:OUT&BD00,v:GOTO 20

And now try arrow keys to move screen in 8 directions. :)
Powered by SMFPacks Menu Editor Mod