def key_to_scan_codes(key, error_if_missing=True):
if _is_number(key):<EOL><INDENT>return (key,)<EOL><DEDENT>elif _is_list(key):<EOL><INDENT>return sum((key_to_scan_codes(i) for i in key), ())<EOL><DEDENT>elif not _is_str(key):<EOL><INDENT>raise ValueError('<STR_LIT>' + str(type(key)) + '<STR_LIT>' + repr(key) + '<STR_LIT:)>')<EOL><DEDENT>normalized = normalize_name(key)<EOL>if normalized in sided_modifiers:<EOL><INDENT>left_scan_codes = key_to_scan_codes('<STR_LIT>' + normalized, False)<EOL>right_scan_codes = key_to_scan_codes('<STR_LIT>' + normalized, False)<EOL>return left_scan_codes + tuple(c for c in right_scan_codes if c not in left_scan_codes)<EOL><DEDENT>try:<EOL><INDENT>t = tuple(_collections.OrderedDict((scan_code, True) for scan_code, modifier in _os_keyboard.map_name(normalized)))<EOL>e = None<EOL><DEDENT>except (KeyError, ValueError) as exception:<EOL><INDENT>t = ()<EOL>e = exception<EOL><DEDENT>if not t and error_if_missing:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(repr(key)), e)<EOL><DEDENT>else:<EOL><INDENT>return t<EOL><DEDENT>
Returns a list of scan codes associated with this key (name or scan code).