I am working on a simple in-fix to post-fix converter. I want to get the user's input from the keyboard. To enter some symbols, e.g."+", the user must press shift. I am using a KeyCombination object to capture whether the user is using shift or not.
My code keeps give me this error: Key code must not match modifier key!
However, when I look at the keycode, it is not Shift, rather it is whatever number row key is pressed. E.g., if the user presses Shift + =, the keycode is EQUALS, not the Shift_DOWN modifier. The code works as expected, but I can't figure out how to get rid of this exception.
tfInput.setOnKeyPressed(e -> {
if (e.isShiftDown()) {
KeyCombination kc = new KeyCodeCombination(e.getCode(),
KeyCombination.SHIFT_DOWN);
userInput = kc.toString();
}