I have a Java Swing app in Which I have been able to set shortcut keys using the following piece of code. For example Ctrl+K.
keyHelp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK));
keyHelp.setMnemonic((int) 'K');//This is the Line I need Help in
I just can't figure out how to add the same using F1 key as the shortcut... Could anyone please help?
Using Action
, as shown here and here, can make these settings easier to manage. Also consider getMenuShortcutKeyMask()
instead of assuming Event.CTRL_MASK
.
use,
KeyEvent.VK_F1
I think it will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With