6
$\begingroup$

I tried to modify the KeyEventTranslations.tr file in order to always place a closed bracket instead of an open bracket once I press [. However once I press [ after the modification nothing happens (the cursor just stays at the same position and not even a [ is placed).

Item[KeyEvent["["],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "[", After],
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "]", Before]
        }]], 

the Code is a slight modification of what i found regarding double brackets:

Automating Esc [[ Esc formatting?

(There is a comment below the top answer, which also mentions Problems regarding [ and German keyboard language).

If I use a different character like / to trigger the KeyEvent, which does not have to be typed using the AltGr-key

Item[KeyEvent["/"],
        FrontEndExecute[{
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "[", After],
            FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
                "]", Before]
        }]], 

the closed bracket will be placed as expected. Other keys like { using AltGr do not work either.

I tried renaming the term.dll files as suggested here:

Is it possible to get AltGr key to work in Math.exe?

unfortunately this did not fix the Problem.

Additional Information: I'm using Win7 and my keyboard language is set to German. (And I would like to keep it set to German).

If there is any other way circumventing the KeyEventTranslations.tr to automaticaly place [] with the cursor placed between the brackets once I press [, it would be fine as well.

Thanks in advance if anyone tries to answer my question :)

$\endgroup$
6
  • 3
    $\begingroup$ Are aware of the fact that Alt-] inserts a matching [ ] pair? No modifications necessary. $\endgroup$ Commented Apr 13, 2014 at 13:17
  • $\begingroup$ With keyboard language set to german that does not work for me. Pressing AltGr-Alt-8 (AltGr-]) does not yield any front end input for me. As a side note: Pressing Ctrl-Alt is equivalent to pressing AltGr on my keyboard. $\endgroup$
    – Max1
    Commented Apr 13, 2014 at 13:50
  • $\begingroup$ With exception to basic editing and saving commands (Ctrl-A, Ctrl-S etc.) keyboard shortcuts do not work when keyboard locale is not set to English. Also the FrontEnd generally cannot handle correctly characters outside of Unicode level 0. $\endgroup$ Commented Apr 13, 2014 at 16:05
  • 1
    $\begingroup$ How about using FrontEndExecute[FrontEndToken["InsertMatchingBrackets"]] instead of the two FrontEndExecutes you used? $\endgroup$ Commented Apr 13, 2014 at 16:12
  • $\begingroup$ @SjoerdC.deVries I just tried, but it did not work. The problem is probably the KeyEvent["["]. In case there exists no proper solution I will just map [] to ), since I mapped () to ( I dont really need the ) key anymore. $\endgroup$
    – Max1
    Commented Apr 13, 2014 at 16:47

0

Your Answer

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

Browse other questions tagged or ask your own question.