Implemented keyboard event handling.