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

Can't toggle modifier keys #39

Closed
cool-RR opened this issue Oct 15, 2019 · 11 comments
Closed

Can't toggle modifier keys #39

cool-RR opened this issue Oct 15, 2019 · 11 comments

Comments

@cool-RR
Copy link

cool-RR commented Oct 15, 2019

I've been trying to toggle the modifier keys, but I guess I'm doing something wrong:

>>> autopy.key.toggle(autopy.key.Modifier.ALT, False, [])
TypeError: Expected string or key code

How should this be done?

@msanders
Copy link
Contributor

It should be: autopy.key.toggle("x", False, [autopy.key.Modifier.ALT]).

@msanders
Copy link
Contributor

This looks like a dupe of #29, will have to add an example to the docs somewhere.

@msanders msanders added documentation duplicate This issue or pull request already exists labels Oct 20, 2019
@cool-RR
Copy link
Author

cool-RR commented Oct 21, 2019

@msanders Where's the "x" coming from? I want toggle just the modifier key, nothing else.

@msanders
Copy link
Contributor

Have you tried autopy.key.toggle("", False, [autopy.key.Modifier.ALT])? I think that should work but don't have time to test it out right now.

@cool-RR
Copy link
Author

cool-RR commented Oct 25, 2019

Nope:

TypeError: Expected string or key code

@msanders
Copy link
Contributor

Ah I see. It looks like we need to add those as individual key codes, e.g. https://github.com/servo/core-foundation-rs/blob/8793a46/core-graphics/src/event.rs#L53.

@msanders msanders added enhancement New feature or request and removed documentation duplicate This issue or pull request already exists labels Oct 28, 2019
@msanders
Copy link
Contributor

Actually it looks like this is already available, just missing from the docs:

autopy.key.tap(autopy.key.Code.META, [])

@msanders msanders removed the enhancement New feature or request label Oct 28, 2019
@cool-RR
Copy link
Author

cool-RR commented Oct 29, 2019

Well, that sends the key, doesn't it? What I want is to toggle off the modifiers, in case they were pressed.

@msanders
Copy link
Contributor

This should work: autopy.key.toggle(autopy.key.Code.META, False, []), was just pointing out the key code.

@cool-RR
Copy link
Author

cool-RR commented Oct 30, 2019

Okay, that works. Should be included in the docs, right?

@msanders
Copy link
Contributor

👍 yup, should be included now.

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

No branches or pull requests

2 participants