Corrected keyboard interrupt code

Bugs pointed out by Harald Wille