← Back to Courses
module
35

Appendix V - The keyboard matrix

Every key on the Einstein sits at one crossing point of an 8 x 8 electrical grid: eight rows your program selects one at a time, and eight columns it reads back as one byte per row. S25 covers how to do the reading; this appendix is the map it reads from.

How to read this table

  • Select row n by writing the byte in the select column to AY register 14 - it is 255 with bit n taken away.
  • Read AY register 15. Each key in that row owns one bit of the answer.
  • The matrix is active-low, both directions: the select byte has one 0 bit, and a held key reads as a 0 in its column bit. A row with nothing held reads 255.

Keys with two legends are shown unshifted first: 2 " is the 2 key, which shifts to ".

Row bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 select
0 ESC SPACE ENTER CAPS F7 F0 - BREAK 254
1 0 @ ½ ‖ DOWN - £ LEFT P O I 253
2 F5 9 ) TAB RIGHT : * ; + L K 251
3 F4 UP = - DELETE 8 ( / ? . > , < 247
4 F3 1 ! 2 " 3 # 4 $ 5 % 6 & 7 ' 239
5 F2 Q W E R T Y U 223
6 F1 A S D F G H J 191
7 F6 Z X C V B N M 127

Row 0 bit 1 is empty - no key lives there.

Reading a key from the table

W is row 5, bit 5. So:

        LD A,14         ; the row-select register
        OUT (2),A
        LD A,223        ; row 5's select byte
        OUT (3),A
        LD A,15         ; the column register
        OUT (2),A
        IN A,(2)
        BIT 5,A         ; W's bit
        JR Z,pressed    ; zero means held

The letter rows repay a look: row 5 is the keyboard's QWERTY row, bit 6 to bit 0 reading Q W E R T Y U left to right, and rows 6 and 7 are the rows beneath it. The grid is the physical keyboard, wired.

Cursor keys and the rest

The cursor keys are ordinary matrix keys - DOWN and LEFT in row 1, RIGHT in row 2, UP in row 3 - so a game can use them exactly like letters, and a two-player game can put one player on WASD and the other on the arrows with nothing but different rows in the scan.

SHIFT, CTRL and GRPH are not in the matrix. They are wired separately, and this table cannot see them - prefer ordinary keys for game controls.

Notes for old listings

Other references print this table with its columns numbered the opposite way - column 0 on the left meaning bit 7. If a map you find seems to contradict this one, read its column n as bit 7 - n and the two will agree. When in doubt, trust the bit your own scan shows you: hold the key and look.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.