Fix keyboard code to work as on real hardware