Question

What are VK_META and META_MASK in the Java Robot class? Any example that explains what they are or what they do would be very helpful.

Also, VK_META gives me an invalid keycode error on my Windows 7 PC.

Was it helpful?

Solution

VK_META and META_MASK are defined in KeyEvent and InputEvent classes. They both define the META key as a standalone key pressed and as a modifier used pressing another key respectively.

The META key is a key used in old keyboards and now can be emulated using the Windows Key.

Robot class allows to simulate key strokes (pressed, released, typed) and mouse movement, "acting" as a user using the keyboard and mouse. When you use the robot class, you define the sequence of "actions" to simulate, mouse movements and keyboard usage. If you want to simulate the META key pressed or used as a modifier, need to pass the keyCode and these two constants define the keyCode for META typed and modifier.

You can have problems using this key depending some factors, such your keyboard layout, keyboard configuration, operating system...

If you have problem, try avoid using this key except you need to simulate the Windows (PC) or Command (Mac) key.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top