Hi there.
Is there a way to check the key state of the ESC key on the Amstrad CPC target?
I need to find a way to go back to the main menu of my program from within the game.
Thanks.
ESC key on CPC
-
- Site Admin
- Posts: 191
- Joined: Fri Oct 06, 2023 8:25 pm
Re: ESC key on CPC
Hi ervin, nice to read you!
Take, for example, this code:
If you run it, it will print a series of 255 (which is the equivalent of "no keys pressed"). If you press the ESC key on the Amstrad keyboard, it will print the number 66. That number can be used with this program:
You could check for any value that come from SCANCODE, and use it in KEY STATE.
Take, for example, this code:
Code: Select all
DO
PRINT SCANCODE
LOOP
Code: Select all
DO
IF KEY STATE(66) THEN
PRINT "GO TO MAIN MENU"
ENDIF
LOOP
You could place control with the KEY STATE statement anywhere in your program, but the best place is definitely in a game loop, where you can periodically check the pressure.