Page 1 of 1

Responsive input with inkey$? How?

Posted: Sat Mar 02, 2019 1:29 pm
by Fabrizio Caruso
Hi everyone!
I am struggling to get my little BASIC 10-liner game to detect key-presses in a more responsive way:
https://github.com/Fabrizio-Caruso/Sinc ... ectrum.bas

In my code I am doing something like:
LET s=CODE INKEY$
LET lr = (s=108)-(s=106): LET ud = (s=107)-(s=105)
LETpx = px+lr: LET py = py+ud
but for some reason, INKEY sometimes skips some key-presses.
Is there a better way to read the keyboard status in BASIC?

Image

Fabrizio

Re: Responsive input with inkey$? How?

Posted: Sun Mar 03, 2019 3:02 am
by djnzx48
You could try using CHR$ PEEK 23560 instead of INKEY$ (or use LET s=PEEK 23560). It returns the last pressed key instead of the currently pressed key, so it could detect keystrokes that would normally be skipped. The downside is you can't use it to tell when no key is being pressed, but you could maybe clear it with POKE 23560,0 after you've checked for a key.