Implemented keyboard_lastkey with help from greg.