The C64 reads the keyboard data from the memory map, as 8 rows
of 8 columns.
Where there are two characters shown the second is the shifted
character.
Characters that may cause trouble due to PS/2 keyboard
incompatibilities are coloured red.
The row bits are selected by writing to the memory-mapped CIA1
port A at address 0xdc00.
The column data bits are read from the CIA1 port B at address 0xdc01.
| Row | Data (read on port B at 0xDC01) | ||||||||
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ||
| 0 | f5 | f3 | f1 | f7 | ret | del | |||
| 1 | sh.L | E | S | Z | A | W | |||
| e | s | z | 4 | a | w | 3 | |||
| 2 | X | T | F | C | D | R | |||
| x | t | f | c | 6 | d | r | 5 | ||
| 3 | V | U | H | B | G | Y | |||
| v | u | h | b | 8 | g | y | 7 | ||
| 4 | n | k | m | o | j | i | |||
| N | 0 | K | M | O | J | L | 9 | ||
| 5 | , | @ | : | . | - | L | P | + | |
| l | p | ||||||||
| 6 | / | uparrow | = | sh.R | home | ; | * | £ | |
| 7 | run/stop | C= | sp | 2 | ctrl | esc- | 1 | ||
PS/2 Scan code to C64 Matrix conversion
| PC kbd |
--> | PS/2 interface |
-scan-code-> | FIFO | -> | C64 Keyboard Matrix Encoder |
<-- 4-bit row addr --> 8-bit row data |
C64 CIA1 chip |
| <-- | <-control-codes- | <-- | encoder | <-- status for LEDs |
C64 Keyboard connector pinout
| Pin | Port bit |
CIA pin |
Function | |
| 1 | GND | GND | ||
| 2 | N.C. | polarity mark | ||
| 3 | RESTORE | This key pulls this pin low to cause an NMI | ||
| 4 | VCC | +5V | ||
| 5 | PB3 | 13 | row 3 | joystick 1 right |
| 6 | PB6 | 16 | row 6 | |
| 7 | PB5 | 15 | row 5 | |
| 8 | PB4 | 14 | row 4 | joystick 1 fire |
| 9 | PB7 | 17 | row 7 | |
| 10 | PB2 | 12 | row 2 | joystick 1 left |
| 11 | PB1 | 11 | row 1 | joystick 1 down |
| 12 | PB0 | 10 | row 0 | joystick 1 up |
| 13 | PA0 | 2 | column 0 | joystick 2 up |
| 14 | PA6 | 8 | column 6 | "1" -> paddle set A |
| 15 | PA5 | 7 | column 5 | |
| 16 | PA4 | 6 | column 4 | joystick 2 fire |
| 17 | PA3 | 5 | column 3 | joystick 2 right |
| 18 | PA2 | 4 | column 2 | joystick 2 left |
| 19 | PA1 | 3 | column 1 | joystick 2 down |
| 20 | PA7 | 9 | column 7 | "1" -> paddle set B |