Search code examples
javaunicodekeyboardkeyboard-shortcutskeystroke

How to allow configurable shortcuts for all languages, i.e. how to map unicode keystrokes to javax.swing.KeyStroke?


I want to allow a shortcut configuration for my application that works around the world. That's why I load them from resource bundles. I first wanted to simply put the resource value for the shortcut directly to javax.swing.KeyStroke.getKeyStroke(String), but that doesn't work for unicode keyboards, e.g. arabic:

KeyStroke test = KeyStroke.getKeyStroke("control ش");
// test is null, i.e. it did not work

ش is the arabic keyboard key of A.

Is there a easy way to allow String definition of international keystrokes for java?


Solution

  • It does not work with pressed keystrokes:

    KeyStroke test = KeyStroke.getKeyStroke("control typed ش");
    // test not null, works