How to change keyboard layout in vpythons keyboard input

13 views
Skip to first unread message

Avedis Neehus

unread,
Jan 5, 2018, 10:23:42 AM1/5/18
to VPython-users
As stated in the title I'm looking for a way to change the keyboards layout to match my keyboard. If there is no simple switch, is there already code that projects keys from one layout to another? I'm also looking for code that that takes any key and concatenates its value to a string automatically. 

Bruce Sherwood

unread,
Jan 5, 2018, 10:43:37 AM1/5/18
to VPython-users
I don't know how to change the keyboard layout, but here is the documentation about accepting a keypress and adding it to a string:

Avedis Neehus

unread,
Jan 5, 2018, 2:27:40 PM1/5/18
to VPython-users
It turns that no bijection between keysigns is possible, since some keys map into nothing (f.e 'shift + 0' equals '=' in my layout, but '' in the standart one). So my solution doesn't work. Also I read the doc, but it doesn't recognize multicharacters, which would have to be written out explicitly. My current idea is to use the clipboard and write the string in separate files, which doesn' seem very elegant. Considering that other types of keyboard layouts like 'QWERTZ' are fairly widespread, I'm sure implementing that feature would be much appreciated.

Kevin Karplus

unread,
Jan 5, 2018, 2:59:52 PM1/5/18
to vpytho...@googlegroups.com
In Python, keyboard mapping is usually handled by the operating system, though pypi has a module to give you full control (https://pypi.python.org/pypi/keyboard/).
You did not say what operating system you were using, nor why its keyboard mapping was not working for you.

Undergraduate Director, Bioengineering and Bioinformatics
Professor of Biomolecular Engineering, University of California, Santa Cruz
Affiliations for identification only.


--
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Avedis Neehus

unread,
Jan 5, 2018, 5:47:19 PM1/5/18
to vpytho...@googlegroups.com
I am using windows 10 v.1709 with a german QWERTZ layout. The keys I need that arent mapped correctly are: [];=


Virenfrei. www.avast.com

2018-01-05 20:59 GMT+01:00 Kevin Karplus <kar...@soe.ucsc.edu>:
In Python, keyboard mapping is usually handled by the operating system, though pypi has a module to give you full control (https://pypi.python.org/pypi/keyboard/).
You did not say what operating system you were using, nor why its keyboard mapping was not working for you.

Undergraduate Director, Bioengineering and Bioinformatics
Professor of Biomolecular Engineering, University of California, Santa Cruz
Affiliations for identification only.


On Fri, Jan 5, 2018 at 11:27 AM, 'Avedis Neehus' via VPython-users <vpython-users@googlegroups.com> wrote:
It turns that no bijection between keysigns is possible, since some keys map into nothing (f.e 'shift + 0' equals '=' in my layout, but '' in the standart one). So my solution doesn't work. Also I read the doc, but it doesn't recognize multicharacters, which would have to be written out explicitly. My current idea is to use the clipboard and write the string in separate files, which doesn' seem very elegant. Considering that other types of keyboard layouts like 'QWERTZ' are fairly widespread, I'm sure implementing that feature would be much appreciated.

Am Freitag, 5. Januar 2018 16:43:37 UTC+1 schrieb Bruce Sherwood:
I don't know how to change the keyboard layout, but here is the documentation about accepting a keypress and adding it to a string:

--
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "VPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vpython-users/V9Cb28hxdtQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vpython-users+unsubscribe@googlegroups.com.

Kevin Karplus

unread,
Jan 5, 2018, 6:28:44 PM1/5/18
to vpytho...@googlegroups.com
I've seen a number of posts on the web about Windows 10 getting the keyboard layouts wrong.  Apparently changing the language, rebooting, then changing the language to the correct one and rebooting again sometimes fixes the problem.

Undergraduate Director, Bioengineering and Bioinformatics
Professor of Biomolecular Engineering, University of California, Santa Cruz
Affiliations for identification only.


Avedis Neehus

unread,
Jan 6, 2018, 4:45:10 PM1/6/18
to vpytho...@googlegroups.com
When calling 'win32api.GetKeyboardLayout()' in the script I get the desired result (german layout). For all other applications the correct layout is also recognized, so I think the problem lies elsewhere.

2018-01-06 0:28 GMT+01:00 Kevin Karplus <kar...@soe.ucsc.edu>:
I've seen a number of posts on the web about Windows 10 getting the keyboard layouts wrong.  Apparently changing the language, rebooting, then changing the language to the correct one and rebooting again sometimes fixes the problem.

Undergraduate Director, Bioengineering and Bioinformatics
Professor of Biomolecular Engineering, University of California, Santa Cruz
Affiliations for identification only.


Reply all
Reply to author
Forward
0 new messages