-
Notifications
You must be signed in to change notification settings - Fork 244
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
type_string character sets #46
Comments
a full UK layout is this incase anyone was wondering.. (!)
I'm totally stumped on the workaround for this.. |
|
its a tricky one for sure. I'm trying to find a solution for the mac which you can read about here - not sure if I'm/we're going to get anywhere though... |
I think @abarnert may have come up with a potential solution. We have (I have a fork on my machine) a keycode library that now (successfully!) looks up any keycode from a character and it returns with the modifier for that character as well as the keycode. E.g. ChatToKeyCode('H') returns (4,2) first num: keycode, second num: modifier key. With this type_string on the mac becomes far easier and reliable across any layout abarnert/pykeycode#3 (see https://github.com/abarnert/pykeycode/blob/ctypes/keycode.py for the code..) I have no idea what would be needed for windows/linux for this to work but it makes logical sense to me that lookup_character_value should return this key:modifier for all platforms. It would also make sense that their should be a lookup_keycode_char fn to for completeness (so you can enter via a raw keycode in pyKeyboard as well as by character). My feeling is that these two functions should form the base of keycode fetching rather than using the dicts. What do you think? Would this work for Win/*nix? I will work on completing this fork over the weekend (and merging with the latest PR) - might make more sense that way! |
I now have a working fork at https://github.com/willwade/PyUserInput Things changed which I wouldn't mind having a bit of musing over before I do a PR..
is now in mac.py k.tap_key('Alternate') Note there is an issue with modifiers:
so 'Shift' 'Command' (Windows key on a win keyboard) 'Control' Alternate' are the modifiers. There should be a standard across all platforms surely? (NB: Aliases) This now means that type_string is really simple:
All shifted chars now work. There is a downside - see: k.tap_key('p')
before this would have given the same 'p' because it always find the lowered form. the new code will potentially mess up old code but I actually think is better.. (or what should be expected) To send some dodgy looking chars: k.tap_key(u'£') is how to do it. Not perfect IMHO. mac_keycode could do with some tidying - maybe even bringing into mac.py. The ctypes implementation (see this thread) may be better to use if so Please reference @abarnet if this happens. Let me know any thoughts and I can do a PR if required |
@willwade: I wouldn't worry too much about getting all the modifiers across every platform; the only ones that normally produce extra symbols are shift (all platforms), option/alt/open-apple (Mac only) and alt-gr/compose (Linux only). (Control also produces extra characters, but only non-printable ones.) So, you might just want to have two modifiers in your abstract layer: Shift, plus one with a bunch of aliases for Opt, Alt-Gr, etc. Also, I think you want my code in layout.py, not the code in keycode.py. I should probably clean things up, merge the branch back to trunk, get rid of the compile step in setup.py, etc. so you can just use it directly. Plus, you probably want to take advantage of the dead-key support; as a Mac user, I'd be disappointed if Also, I haven't looked at what you're doing on linux, but both xim and gim have similar dead-key support to Mac (but only for simple dead keys). (Also, are you handling Ctrl-Shift-U on linux and Alt-KP on Windows? Because that lets you type a whole lot more characters, a lot more easily.) |
@SavinaRoja Since the keycodes vary based on the OS, how can i get the keycode for the same button for other OS. For instance, the backspace Keycode in Windows is 8, however i cant use that in Linux as in that is 20. |
this won't work;
Reason being is that ch_index (line 64 in base.py) is only for US keyboard layouts..
It could be over ridden but this may not be the neatest solution..
The text was updated successfully, but these errors were encountered: