Detect press on Windows Logo key via Java

Don Erikstrup 0 Reputation points

I have a Java program I have written myself to do diagramming, something like the architecture programs out on the market. When drawing certain structures, I use the keyboard modifier keys (ALT, SHIFT, CTRL, META) to determine what the user wants to do as s/he draws the structure on the canvas. This works pretty well on a Mac, in which I can detect when the "Command" key is pressed via the MouseEvent.getModifiersEx() method. I tried to do this with a MS Windows platform to detect if the Windows Logo key was pressed. No luck. I also tried to detect if the "fn" key was pressed. I wasn't surprised when I could not detect that either. The Mac doesn't inform me about it either. I suspect the "fn" key on both MacBook and Windows (a Dell G15, BTW) keyboards is handled entirely by the keyboard.

So my question is: How do I detect when the Windows Logo key is pressed?

Ancillary questions: Is the Windows Logo key even similar in usage to the Mac Command key? That is, is it treated like any other key on the keyboard? And if so, what key would trigger a "MouseEvent.isMetaDown()" positive (true) response in Java on a Windows platform?

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,885 questions
0 comments No comments
{count} votes