5
$\begingroup$

How can I define a keyboard shortcut based on an umlaut like ü?

KeyEvent in KeyEventTranslations.tr doesn't seem to register umlaut based keyboard inputs. For example, after adding

Item[KeyEvent["ü", Modifiers -> {Control}], FrontEndExecute[FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], "{", After]]],
Item[KeyEvent["\[UDoubleDot]", Modifiers -> {Control}], FrontEndExecute[FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], "{", After]]],
Item[KeyEvent[\[UDoubleDot], Modifiers -> {Control}], FrontEndExecute[FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], "{", After]]],
Item[KeyEvent["ü", Modifiers -> {Command}], FrontEndExecute[FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], "}", After]]],

to KeyEventTranslations.tr pressing Ctrl+ü or Alt+ü in the front-end (using a German keyboard layout) only produces a beep. The message in the "Why the Beep?" window states

You used a Command or Control key combination that is not defined to do anything.

However, adding

Item[KeyEvent["+", Modifiers -> {Control}], FrontEndExecute[FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], "}", After]]],

does work as expected.
Also the EventHandler does understand umlaut based key events correctly, e.g.,

DynamicModule[{col = Green}, 
 EventHandler[Style["text", FontColor -> Dynamic[col]], 
  {{"KeyDown", "ü"} :> (col = col /. {Red -> Green, Green -> Red})}]]

Is it completely impossible to have keyboard shortcuts in Mathematica that are based on umlaut? Or is there another key code one has to input into KeyEvent instead of "ü" or "\[UDoubleDot]"?

$\endgroup$
  • $\begingroup$ Maybe you can do it the hard way, using low level (like OS or driver) API. $\endgroup$ – Silvia Sep 27 '16 at 19:47
  • 1
    $\begingroup$ @Silvia I tried it the OS way (creating a custom keyboard layout), but it doesn't work inside the front-end. Hence I asked this question previously. All the [, {, }, and ] are like yoga for the right hand on a German keyboard. $\endgroup$ – Karsten 7. Sep 27 '16 at 20:18
  • 1
    $\begingroup$ hmm... have you tried simulating a USB keyboard by directly writing to certain USB port? That way no one will realize it's a fake. I'm on mobile phone so not easy to post a link, but as a start you can try searching USBPcap. $\endgroup$ – Silvia Sep 28 '16 at 10:49
  • 1
    $\begingroup$ @Silvia Thanks for that hint. USBPcap is supported by Wireshark, which I had to update anyway. I'll try it out over the weekend. Thanks. $\endgroup$ – Karsten 7. Sep 28 '16 at 11:23
  • $\begingroup$ You're welcome! Please do let me know if it works! $\endgroup$ – Silvia Sep 29 '16 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.