If you have a full-sized printer you might appreciate this circuit which generates the series of characters for the ESC escape control code – CHR$27; – with one keystroke. The circuit can be implimented if you use 4066’s to interface the keyboard with the computer.
Here’s how Figure 1 works. Two NAND gates form an 18Hz clock. This is as fast as the computer can digest if you have more than three lines in the PRINT statement. The 18 Hz wavetrain is feed to the clock input of a 4017 counter. The 4017 has 10 decoded outputs – 0 through 9. When the computer is fired up, the 4017 counts up to 9 before the computer has completed its startup routine. When output 9 goes high, the counter is disabled. When the keyboard switch is depressed, a NAND gate used as an inverter resets the counter to zero thus enabling it to count again. As it counts back up to 9 the appropriate keyboard lines are switched in sequence through the 4066’s.

Power for this little circuit and the 4066’s was taken from the output pin of the UA78L12 regulator on the computer board. It’s the little one, near the big electrolytic capacitors, that looks like a transistor. If your 4066’s are powered from 5v at present, be sure to change to the 12v supply. Its a good idea anyway – the higher supply voltage gives better noise immunity and allows you to use two diodes in series in the switching logic lines if you want to.