Phone Input

Publicado 2023-06-12


(v00 10-28-22)
TO LOAD THIS PICO-8 CART, in immediate mode, type: load #phoneinput

Hello there !

To try out the code above, use the arrow keys to navigate, the 🅾️ key to select a character and the ❎ key to erase it. For a real challenge try typing out, "NEIGHBOR" as quickly as you can.

Since it may be a-while for Pico-8 to have its own onboard keyboard to let you type in your name for games and stuff, I was thinking of the marvel of a touch-tone telephone and how you can type in a name for instance for speed-dial.

Well it's pretty nifty what it does. On my own real phone for instance:

You can see the digits yet you can also see some smaller letters. For instance if you wanted to type out, "DIRK" for Dirk The Daring, then on this keypad you would press: 3 444 777 55

I liked how simple this was so I made my own. Above it functions just the same way except instead of blending the digits with the letters I gave the digits their own row above and the zero is just after the Z seen just above the CR key.

It's also interesting in that if you want to repeat a letter. Let's say the T in BATTER, then you would select the T and then not press anything. After a short pause it will be typed then you can type it in again.

If you don't want to wait for the key to be typed, pressing any arrow key to go to the next selection automatically makes your choice character the one to choose and adds it without delay to your message string.

In this you can rapidly enter text and even digits for your input. And I did not set a length. You can have the input as long as you like, it will intelligently scroll it for you.

Unlike other Pico-8 functions, however, this one will FREEZE your main code (except playing music which continues) while only my function works - and continues to do so until you select the text you want. Then your program will resume as normal with the results of the function.

This makes it a lot easier to call and not have to worry about the rest of your code running alongside it.

It also records the screen contents so you don't need to redraw after calling it and at no cost to either programming memory or extended.

I like this function and will be using it for future projects with a possible change to adding keys that they may be accessed much the same way where you press one key 2- 3- or 4- times in a row to get the extra keys attached you need.

I can add sound too if you want. Little clicks and stuff when you navigate and select. Those are some minor details, though.

For now this function works great as is. It is 414-tokens or 918-typed characters at 14-lines of code. You can copy/paste it in your own code and you don't need to press CTRL+P first either. It just uses normal text characters.

If this helps you in your code, please let me know !