When I use this code, I get "Delete" as a shortcut. I want to get "Del" (delete key)
private JMenuItem delRef = null;
del = new JMenuItem("delete");
del.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
When I use this code, I get "Delete" as a shortcut. I want to get "Del" (delete key)
private JMenuItem delRef = null;
del = new JMenuItem("delete");
del.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
Copyright © 2021 Jogjafile Inc.
From an answer in a related post, I found out that the
keyCode(first parameter ofgetKeyStroke) which you are requesting is110.Then I did:
Which prints
pressed DECIMAL.So the
keyCodeyou are looking for is actuallyKeyEvent.VK_DECIMALand it will only work (at least as far as I tested it) for the numpad's delete key (only when numlock is on).So to answer, you can use: