Edited keyboard input handler.