Getting Caps Lock
status :)
#221
villares
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Neat! Thank you for sharing this. If you want to make it even more elegant, you can try this: import py5
from java.awt import Toolkit JPype does some Python sorcery to make importing Java packages look like importing Python libraries. Anything on the classpath is applicable. py5 sets this up for you when it is imported (after it starts the JVM). You can then import Happy coding! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Back in 2018 I had a sketch in Processing Python mode where I wanted to use the
Caps Lock
status as an interface input, to change "view modes".One can check for
key == CODED and key_code == 20
to see ifCaps Lock
was pressed, but then you have to keep track of the status in a global flag variable, etc., and I didn't want any of that... (and you actually can track changes but not the the initial status...) so I went digging and foundjava.awt.Toolkit.getDefaultToolkit().getLockingKeyState(20)
.You can still do that with py5! You just have to import
java
fromjpype
. As a bonus, while I was rewriting this example, I found out thatkey
seems to start asNUL
/chr(0)
at the start of a sketch, good to know, I suppose...PS: The Noto fonts, named after the noble goal of "No Tofu", no missing glyphs, just doesn't live to its aspirations: ASCII 20 "Device Control 4" has no glyph! 😆 .
UPDATED: I updated with the tip bellow from @hx2A!!!
Beta Was this translation helpful? Give feedback.
All reactions