Replaced UI_* constants in event listener code with regular element selectors. Moved keydown and keyup event listener code into two separate functions handleDocumentKeyDownEvents() and handleDocumentKeyUpEvents(), respectively.