Added detection code for modifier keys and restructured some keyboard events.