Reorganize key press functions.