PyUserInput
PyUserInput copied to clipboard
lookup_character_value ??
What was the initial thinking behind lookup_character_value in pykeyboard base?
I'm only asking as I want to press a key based on its virtual key code.. I was guessing this function was the intention of looking up the key code and mapping it to the string form?? Happy to edit the mac, win, linux builds to do the lookup if this is the functions intention!
thanks!
The notion of lookup_character_value
is pretty much as you describe, though the name is not used in any of the implementations (oops!). lookup_character_keycode
serves this role in the X11 implementation, perhaps the naming should be rectified. As for Windows and Mac, I think that they need a similar, though they appear to be less dynamic than X11.
Keyboard handling on different platforms is very different, and the APIs used for each are quite different as well, so internally these implementations may vary wildly. but we do need to provide a unified user-facing interface. I intend for special keys to be assigned generally on instantiation, and convenience methods should be able to lookup keycodes on the fly. Users are unlikely to call lookup_character_keycode
directly, so I would say that giving Mac a proper lookup function and a full set of special key attributes which it will hold like Mac and Linux is the first priority, followed by uniform abstraction/naming.
got you - this relates to the comments in #44 too.
I note that press_keys in windows also uses this:
char_vk = win32api.VkKeyScan(character)
which basically just needs putting separately into a function..
The mac is a pain. I've raised a (question?) on pyKeycode as to how to embed the Objective-C functions that are in the pyKeyCode project into native Python/Quartz (I don't really want to have to use a second library) - my Objective-C knowledge is nill. This does seem to have the solution though..
Update: I have a working version of this on my fork for mac and windows. Note though the mac version is significantly different. It has some big advantages over the current code however I'd like to fix the shifted_characters problem first.. (As an aside - you can also send raw key codes from the base methods simply by typing 'VK_ in front of the key.. Not sure if a good idea or would work in windows that..)
I'd love to help with your fork in any way I can. What is the shifted_characters problem that you are referencing in your comment?
@willwade how is your fork coming along? You seem to have some promising changes. I'm playing with ideas about how to get this project in a healthy state. There is a lot of god stuff here, but everyone is busy, there are issues, and it's dying out.