Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle characters with shift modifiers in FX2D (#5317) #5563

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 75 additions & 0 deletions core/src/processing/javafx/PSurfaceFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,16 @@ private char getKeyChar(KeyEvent fxEvent) {
case MULTIPLY:
return '*';
case SUBTRACT:
case MINUS:
if (fxEvent.isShiftDown()) {
return '_';
}
return '-';
case ADD:
case PLUS:
if (fxEvent.isShiftDown()) {
return '*';
}
return '+';
case NUMPAD0:
return '0';
Expand All @@ -1039,12 +1047,79 @@ private char getKeyChar(KeyEvent fxEvent) {
return '8';
case NUMPAD9:
return '9';
case DIGIT1:
if (fxEvent.isShiftDown()) {
return '!';
}
return '1';
case DIGIT2:
if (fxEvent.isShiftDown()) {
return '"';
}
return '2';
case DIGIT3:
if (fxEvent.isShiftDown()) {
return '§';
}
return '3';
case DIGIT4:
if (fxEvent.isShiftDown()) {
return '$';
}
return '4';
case DIGIT5:
if (fxEvent.isShiftDown()) {
return '%';
}
return '5';
case DIGIT6:
if (fxEvent.isShiftDown()) {
return '&';
}
return '6';
case DIGIT7:
if (fxEvent.isShiftDown()) {
return '/';
}
return '7';
case DIGIT8:
if (fxEvent.isShiftDown()) {
return '(';
}
return '8';
case DIGIT9:
if (fxEvent.isShiftDown()) {
return ')';
}
return '9';
case DIGIT0:
if (fxEvent.isShiftDown()) {
return '=';
}
return '0';
case DECIMAL:
// KEY_TYPED does not go through here and will produce
// dot or comma based on the keyboard layout.
// For KEY_PRESSED and KEY_RELEASED, let's just go with
// the dot. Users can detect the key by its keyCode.
return '.';
case NUMBER_SIGN:
return '#';
case LESS:
if (fxEvent.isShiftDown()) {
return '>';
}
return '<';
case PERIOD:
if (fxEvent.isShiftDown()) {
return ':';
}
return '.';
case COMMA:
if (fxEvent.isShiftDown()) {
return ';';
}
return ',';
case UNDEFINED:
// KEY_TYPED has KeyCode: UNDEFINED
// and falls through here
Expand Down