def hook_key(key, callback, suppress=False):
_listener.start_if_necessary()<EOL>store = _listener.blocking_keys if suppress else _listener.nonblocking_keys<EOL>scan_codes = key_to_scan_codes(key)<EOL>for scan_code in scan_codes:<EOL><INDENT>store[scan_code].append(callback)<EOL><DEDENT>def remove_():<EOL><INDENT>del _hooks[callback]<EOL>del _hooks[key]<EOL>del _hooks[remove_]<EOL>for scan_code in scan_codes:<EOL><INDENT>store[scan_code].remove(callback)<EOL><DEDENT><DEDENT>_hooks[callback] = _hooks[key] = _hooks[remove_] = remove_<EOL>return remove_<EOL>
Hooks key up and key down events for a single key. Returns the event handler
created. To remove a hooked key use `unhook_key(key)` or
`unhook_key(handler)`.

Note: this function shares state with hotkeys, so `clear_all_hotkeys`
affects it aswell.