Fix two bugs in Keyboard implementation