Add keyboard handler

Add a keyboard handler to process key up and key down events, and to
keep track of pressed, released, and held keys.