1
$\begingroup$

I want to remap the alias delimiter from Esc to Ctrl+f (or Ctrl+Shift+f or some other key combo). I have not been able to get the previous solution to the question to work (Rebinding keys to define new keyboard shortcuts).

I copied the file, copy and pasted the code (though I changed it to Control, Shift [1]) into the copied KeyEventsTranslation.tr and placed the copy in my directory (full path: $UserBaseDirectory\SystemFiles\FrontEnd\TextResources\Windows\KeyEventTranslations.tr). I restarted Mathematica and when I hit Ctrl+Shift+f nothing happens. The Escape key still produces the alias delimiter.

I have also tried changing the "Up" key to move to the next line instead of the previous line (i.e. Item[KeyEvent["Up"], "MoveNextLine"]). That does not work either. Pushing the up arrow still moves the cursor to the previous line.


Any help is appreciated.
Thanks.



OS = Windows 10 Pro 64-bit (fully patched)
Mathematica = 10.3.1.0



[1]

Item[KeyEvent["f", Modifiers -> {Control, Shift}],
    FrontEndExecute[{
        FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
            "\[AliasDelimiter]", After]
    }]],
$\endgroup$
2
  • $\begingroup$ Did you try to put it at the end of KeyEventTranslations.tr? $\endgroup$
    – Michal
    Jul 21, 2016 at 20:09
  • $\begingroup$ It seems f is the problem. x works well, I don't know why some keys are not working with Ctrl+Shift even though they are not taken. $\endgroup$
    – Kuba
    Jul 22, 2016 at 5:26

1 Answer 1

2
$\begingroup$

Note that both MenuSetup.tr and KeyEventTranslations.tr define keyboard shortcuts, and when a keyboard shortcut is defined in both files, the one in MenuSetup.tr takes precedence. Sometimes the keyboard short cut in MenuSetup.tr is defined, but not active, and in those situations the identical keyboard short cut in KeyEventTranslations.tr will work. So, let's find the keyboard shortcuts defined in MenuSetup.tr:

System`MenuKey;
Cases[
    Get @ FrontEndExecute @ FrontEnd`FindFileOnPath[
        "MenuSetup.tr",
        "PrivatePathsTextResources"
    ],
    System`MenuKey[Alternatives @@ CharacterRange["A","z"], _],
    Infinity
] //Sort //Column
MenuKey["a",Modifiers->{"Command"}]
MenuKey["b",Modifiers->{"Command"}]
MenuKey["B",Modifiers->{"Command","Shift"}]
MenuKey["B",Modifiers->{"Control","Shift"}]
MenuKey["c",Modifiers->{"Command"}]
MenuKey["C",Modifiers->{"Command","Shift"}]
MenuKey["C",Modifiers->{"Control","Shift"}]
MenuKey["D",Modifiers->{"Command","Shift"}]
MenuKey["e",Modifiers->{"Command"}]
MenuKey["E",Modifiers->{"Command","Shift"}]
MenuKey["f",Modifiers->{"Command"}]
MenuKey["f",Modifiers->{"Command","Control"}]
MenuKey["F",Modifiers->{"Command","Shift"}]
MenuKey["F",Modifiers->{"Control","Shift"}]
MenuKey["g",Modifiers->{"Command"}]
MenuKey["g",Modifiers->{"Control"}]
MenuKey["G",Modifiers->{"Command","Shift"}]
MenuKey["G",Modifiers->{"Control","Shift"}]
MenuKey["H",Modifiers->{"Command","Shift"}]
MenuKey["H",Modifiers->{"Control","Shift"}]
MenuKey["i",Modifiers->{"Command"}]
MenuKey["I",Modifiers->{"Command","Shift"}]
MenuKey["j",Modifiers->{"Command"}]
MenuKey["k",Modifiers->{"Command"}]
MenuKey["K",Modifiers->{"Command","Shift"}]
MenuKey["l",Modifiers->{"Command"}]
MenuKey["L",Modifiers->{"Command","Shift"}]
MenuKey["m",Modifiers->{"Command"}]
MenuKey["M",Modifiers->{"Command","Shift"}]
MenuKey["n",Modifiers->{"Command"}]
MenuKey["O",Modifiers->{"Command","Shift"}]
MenuKey["O",Modifiers->{"Command","Shift","Option"}]
MenuKey["p",Modifiers->{"Command"}]
MenuKey["P",Modifiers->{"Command","Shift"}]
MenuKey["R",Modifiers->{"Command","Shift"}]
MenuKey["S",Modifiers->{"Control","Shift"}]
MenuKey["t",Modifiers->{"Command"}]
MenuKey["t",Modifiers->{"Control"}]
MenuKey["T",Modifiers->{"Control","Shift"}]
MenuKey["U",Modifiers->{"Control","Shift"}]
MenuKey["v",Modifiers->{"Command"}]
MenuKey["w",Modifiers->{"Command"}]
MenuKey["w",Modifiers->{"Command","Option"}]
MenuKey["x",Modifiers->{"Command"}]
MenuKey["X",Modifiers->{"Command","Shift"}]
MenuKey["z",Modifiers->{"Command"}]
MenuKey["z",Modifiers->{"Command","Shift"}]

As you can see, there is already a keyboard short cut for MenuKey["F", Modifiers -> {"Control", "Shift"}], and this short cut is active in the menu system, so it prevents the version in KeyEventTranslations.tr from working.

As for the "Up" key question, the only thing I can think of is that you have two definitions for the KeyEvent, and your new definition was overridden by the later definition.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.