I'm trying to make a key pressed listener for my browser app for Command+T to trigger opening a new tab in the same way that most actual browsers do it.
Looked up some possible solutions for this and it looks like I probably have to use KeyCombination
however I can't find anything for the command key. So far, the closest I've found is Control+T.
private KeyCombination newTab = new KeyCodeCombination(KeyCode.T, KeyCombination.CONTROL_DOWN);
...
root.setOnKeyPressed(event -> {
if (newTab.match(event))
tabPane.getTabs().add(new Tab());
});
I know this currently works fine but I really want to use command instead of control because it's much more natural and intuitive.