Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt Gr with Key throws Exception #55

Closed
RickLatrine opened this issue Mar 28, 2017 · 1 comment
Closed

Alt Gr with Key throws Exception #55

RickLatrine opened this issue Mar 28, 2017 · 1 comment

Comments

@RickLatrine
Copy link

When adding a hot-key with Alt Gr and a character, an exception is thrown.

Example:

keyboard.register_hotkey('alt gr+.', my_callback)

Exception occurs when pressing keys:

  Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\keyboard\_generic.py", line 23, in invoke_handlers
    if handler(event):
  File "C:\Python27\lib\site-packages\keyboard\__init__.py", line 283, in handler
    unexpected = not any(matches(event, part) for part in steps[state.step])
  File "C:\Python27\lib\site-packages\keyboard\__init__.py", line 283, in <genexpr>
    unexpected = not any(matches(event, part) for part in steps[state.step])
  File "C:\Python27\lib\site-packages\keyboard\__init__.py", line 149, in matches
    return matched_name or _os_keyboard.map_char(normalized)[0] == event.scan_code
  File "C:\Python27\lib\site-packages\keyboard\_winkeyboard.py", line 444, in map_char
    scan_code, shift = to_scan_code[name]
TypeError: 'int' object is not iterable

'alt gr,.' isn't working ,too.

I found out that the configration map used to find scan-codes, does not return a tuple with Shift-Flag:

        from_scan_code[alt_gr_scan_code] = ['alt gr', 'alt gr']
        to_scan_code['alt gr'] = alt_gr_scan_code
    finally:
        tables_lock.release()

see Code

The following modification worked for me:

        to_scan_code['alt gr'] = alt_gr_scan_code, False
@boppreh
Copy link
Owner

boppreh commented Mar 28, 2017

Huh, stupid mistake. Thank you for pointing out. It's fixed by the newest commit.

I have to find a way to test these OS-specific backends, but I don't want the tests to press keys or be interactive...

@boppreh boppreh closed this as completed Mar 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants