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

Enable parsing symbols and os-specific string representations of keys (besides modifiers) #214

Open
dalthviz opened this issue Jul 17, 2024 · 0 comments

Comments

@dalthviz
Copy link
Collaborator

Give that a check and I think the work at #213 partialy captures the parse_platform logic at https://github.com/napari/napari/blob/main/napari/utils/interactions.py#L312 The missing thing I would say is also being able to parse symbols from non modifier keys like enter, arrows, backspace, delete, tab, space, etc. Could it be worthy to further extend the parsing capabilities to any symbol or representation that os_symbol and os_name can return? From a quick check, maybe extending the KEYCODE_FROM_LOWERCASE_STRING dictionary could be a way to achieve this? So something like:

KEYCODE_FROM_LOWERCASE_STRING: Dict[str, KeyCode] = {
    # two special cases for assigning os-specific strings to the meta key
    'win': KeyCode.Meta,
    'cmd': KeyCode.Meta,
    # special cases for symbols and other os-specific strings
    '↵': KeyCode.Enter,
    '→': KeyCode.RightArrow,
    ...
}

Originally posted by @dalthviz in #211 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant