I've never used one, so can someone tell me how the Sinclair
ZX81 keyboard works?

Because I'm seeing like 5 options per key, and only one shift key.

Like the "S" key: It's Save, ARCCOS,. "S", LPRINT, and that graphical symbol. How do you select between those?

I'm not even sure how you type backspace on this. shift-0?

I have looked up the manual

this has made me more confused

but the answer seems to be: it's a combination of shift and being modal.
The computer knows when you'd be typing BASIC keywords, so pressing "P" gives you PRINT in that case, no shift required.
you can also do shift-9 to get to graphics mode, which'll let you type the graphics.

and there's some way to get inverse text, but I'm not sure how. it doesn't have lowercase.

So at all types the keyboard is in one of these four modes:
K, L, F, or G.
K gets keywords (above the key), and the red text if shifted.
L gets regular text, and red text if shifted.
F gets the functions under the keys.
G gets the graphics.

You can't intentionally switch to K-mode: it's done automatically at the start of lines or when it needs numbers.

and confusingly, F and G modes work different:
you do shift-newline to get to function mode, but function mode turns off as soon as you press another key.
you do shift-9 to get graphics mode, but it stays in graphics mode until you press shift-9 again.

@foone yea had the timex sinclair 1000, which is essentially the same machine. keyboard did shortcuts to autocomplete stuff, which given how bad the membrane keyboard was, is good as you have to type less, but still not great as you have to use it's screwy shortcut system. I never had a manual, so learning that was painful.
ahh, graphics mode is how you get the inverse text!
in G mode, regular presses give you the inverted uppercase letters, while shift+key gives you the graphics equivalent
now I just need to figure out how to map this to unicode and then also how to figure out how to actually type them because the HID keyboard protocol is a trash fire
unicode does have inverse squared letters, like 🅵🅾🅾🅽🅴, but the ZX81 can do inverse versions of all letters, and there's DEFINITELY not an inverse-square version of £
my keyboard is ready for KEYWORD input
okay I implemented switching between all the modes. I'm gonna take a break now, but the next step will be implementing ALL these fucking keyboard functions.

@foone i would've said "oh go use the keyboard from that american market timex ts1000 thing" but i just looked it up and uhh... yeah they just re-used the original UK keyboard, £ and all

ah sinclair, always cutting every single corner imaginable

@6a62 they cut so many corners it's amazing their computers aren't round
@foone @6a62 they were really cheap (compared to other machines) and sold a fuck tonne in the UK though!
@foone I‘m surprised this is not in Unicode given that one of their stated goals was to allow round trip conversion between it and legacy character sets. :-(
@Landa I think they assumed (or hoped) that there were no ZX81 files still surviving
1▘ 2▝ 3▗ 4▖ 5▌ 6▐ 7▄ 8▀
Q▟ W▙ E▛ R▜ T▞ Y▚
A▒ S🮎 D🮏 F🮒 G🮑 H🮐
@foone yup! That's it! I learned programming on a keyboard like that!
@foone inverse text? The BASIC input line would show you the mode - inverse K for keyword, inverse G for graphics mode - and of course you could manipulate directions and background colour of the output, but inverse wouldn't have been an input feature
@foone I yes except what I believe is actually happening is not that the keyboard code knows any that or does that processing but rather that the BASIC is stored in tokenized form and the codes for those tokens are exactly the letters they're marked as. So when you press PRINT you're actually typing and indeed storing a P and then it's displaying as "print" because the code listing code knows to expect a token there.

@foone

Yes. At the start of a line, the cursor becomes an inverse-video "K" and pressing a key gives you the BASIC keyword in white text above the key. The cursor than turns to an "L" and lets you enter letters.

SHIFT inserts the red characters/keywords. I don't remember if it's modal or not.

SHIFT+NEW LINE puts the cursor in "function" mode and it will then insert the keyword below the keys; these are functions that can be used in expressions.

(ctd)

@foone

SHIFT+9 puts it in graphics mode and lets you enter the special boxy characters next to the letter inside the key. Once again, I don't remember if it's modal or not.

EDIT (SHIFT+1) let you modify a line of your current program.

I don't remember how to do inverse video; I think it was something programmatic. They were done via a hack in the glue logic rather than being part of the character set.

(ctd)

@foone

Also, fun fact: all of the keywords were also characters in the character set. Which helps when you only have 1k of RAM.

@foone

(This was my first computer. I still have it in a box somewhere, actually. I wonder if it still works.)

@suetanvil likely still works, but the PSU may have gone dodgy

@scruss

Mine was assembled for me by a friend's dad who also gave me a non-standard power supply. It had (has?) a metal case with a switch. Nice piece of gear but I have no idea if it'll still work, nor if I'd want to try it.

@suetanvil they're best appreciated in the abstract. Amazed you remembered the key sequences

@scruss

It was my first computer, so it was only up from there. But I learned a lot from it.

Also: from what I know now, it's pretty astounding that they were able to do *that* with *that*.

@foone

Also: now that I think about it, I'm pretty sure that SHIFT wasn't modal. As I wrote this, I had a tactile memory of pressing SHIFT+THEN.

@suetanvil I'm suddenly realizing that I'm re-implementing this keyboard on a microcontroller that's got 256 times as much ram as the whole computer it goes to

@foone

FWIW, I ended up getting a third-party 16K RAM module, so it's only 16 times.

Also, you'll miss out on the experience of losing your work when you bump it a little bit harder than usual.

@foone You can type inverse text by going into Graphics input and typing the letters. The graphics characters themselves need Graphics input and then Shift+key. And a solid black square is just the inverted space character.
@foone it doesn't even use ASCII
@foone the model 15 had a similar modal shift -- press FIGS to start sending numbers and symbols, press LTRS to go back to alphabetics. Or send a newline or whitespace, depending on the options install in the *receiving* end.
@foone or the Russian version, press "1..." for numbers, "A..." for Roman letters, and "РУС" for Cyrillic. (I'm not sure how the fourth row worked on their teletype)
@foone maybe a 3 button combo for some items. Shift + function then whatevs?
@foone You just wiggle the RAM pack to get rid of mistakes.
@foone Rub out is backspace, yeah
@foone yeah, RUBOUT is just a silly british-ism, a pencil eraser is called a rubber here (no condom jokes please and thank you), hence rub-out
@foone Yes. It's an awful membrane keyboard. The Spectrum was even worse as that had more modifier keys.
@tautology @foone I was just going to say the ZX81 is pretty horrible and the Spectrum improves it by having a separate symbol shift key! 😆​
@tautology oh, I know it's awful: that's the point for why I'm using it
@foone I did recently spend more on a replacement keyboard membrane for my ZX81 than I spent on the ZX81 itself. Such is the retrocomputing hobby.