def stash_state():
<EOL>with _pressed_events_lock:<EOL><INDENT>state = sorted(_pressed_events)<EOL><DEDENT>for scan_code in state:<EOL><INDENT>_os_keyboard.release(scan_code)<EOL><DEDENT>return state<EOL>
Builds a list of all currently pressed scan codes, releases them and returns
the list. Pairs well with `restore_state` and `restore_modifiers`.