Log In  

Cart #gojefesozi-0 | 2019-08-24 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

You may have seen a few rare carts read the keyboard. I wrote this simple program to demonstrate easily how it can be done.

It also introduces two useful functions of CHR() and ASC() where CHR(n) returns the character equivalent from an ASCII value N whereas ASC(n) returns the ASCII equivalent from the character N.

It is important to note that I have reversed the values of 65-90 and 97-122 respectively as in PICO-8, pressing "A" by itself normally gives 97 despite its appearance being uppercase.

You are welcome to change the table back if you like.

If you don't want to use BTNP() or BTN() to return your arrow keys, you can hit NUM-LOCK and use "2" "4" "6" and "8" respectively to emulate arrow motions. Additionally, "1" "3" "7" and "9" for single stroke diagonals !

This keyboard routine does not read the regular arrow keys nor PgDn, PgUp, Home, End, Ins, Del, Shift, Ctrl, Alt, Caps Lock, or any of the function keys. Nor will it read extended keys such as CTRL followed by a character or ALT followed by a character.

It does however read every remaining key including shift keys A-Z to return the extended set past 126 and Tab, Backspace, Enter, and Spacebar. This does include letter "P" as returnable as in the code I have disabled it.

For this demo, however, You can press "!" to pause this cart to show it can be invoked and the code explains how it is done.


P#66902 2019-08-24 03:50 ( Edited 2019-08-24 04:45)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-05-31 04:33 | 0.016s | 2097k | Q:28