954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

KeyCode Learn a new Key???

Hey,

I am now programming in a MacBook Pro and for the KeyCodes in the Robot Class, there is no set key for Command. Can I set a KeyCode to do the actions of the Command key?

Thanks

caswimmer2011
Light Poster
27 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

The list of VK_... key codes can be found in the JavaDoc for KeyEvent. eg the control key is VK_CONTROL.
I don't know about how the Mac Command key is coded, maybe its its the same as VK_WINDOWS? (easy to try!), but you could write a very small program with a KeyListener and print out the key code that is passed into your keyPressed method,

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

Good idea with the VK_WINDOWS key, but it did not work :( I was trying to avoid that, but I think it is the only way. Would you have any idea how to get started?

caswimmer2011
Light Poster
27 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

Write a small program, implementing keyListener. On the key pressed method, you print out te character.

hiddepolen
Posting Whiz in Training
297 posts since Oct 2010
Reputation Points: 82
Solved Threads: 35
 

I actually found one online and modified it. Turns out to be keycode 157. Thanks for helping!

caswimmer2011
Light Poster
27 posts since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: