Is it by any chance possible to make the Menu key work as one would expect in Mathematica: opening a context menu?

The Menu key does nothing in version 7 or 8 on Windows.

  • 2
    $\begingroup$ Actually I don't recall ever having used this button ;-) $\endgroup$ – Sjoerd C. de Vries Mar 3 '12 at 23:31
  • 3
    $\begingroup$ Perhaps using something like AutoHotKey (autohotkey.com) to map it to some symbol you don't even have in your keyboard and then catching it in MMA with tkott's idea? $\endgroup$ – Rojo Mar 4 '12 at 0:18
  • $\begingroup$ Same issue occurs on Linux. $\endgroup$ – Mechanical snail Nov 25 '12 at 9:27

This isn't a full answer, but maybe those with more knowledge can take it from here.

To capture key presses of a particular key, one can do the following:

 FrontEndEventActions -> {{"KeyDown", "q"} :> (++k), PassEventsDown -> True}

The previous example increments k each time the letter q is pressed. Note: the "PassEventsDown" is important. Without it, q won't ever actually show up in your notebook.

To do more fun things, you can try to call a front end element with the following:


This automatically launches the front end dialog that is mentioned. A full list of Front End Tokens is available here. Putting things together:

 FrontEndEventActions -> {{"KeyDown", "q"} :> (++k; 
   PassEventsDown -> True}

There are two problems here:

  1. I don't know if there is a FrontEndToken corresponding to the "Right Click" / "Contxt" menu
  2. I don't know if there is a name for the Menu Key
  3. I have no idea what I'm doing with the SetOptions[$FrontEndSession]... I might have broken other things.

Maybe you can hack together something from this!

  • $\begingroup$ Something like 'a FrontEndToken corresponding to the "Right Click" / "Contxt" ' menu would be crucial. $\endgroup$ – Andrew Mar 3 '12 at 22:59
  • $\begingroup$ @AndrewMacFie To be more specific, I haven't look through each and every front end token they have listed, so there might be something there. Also, you could probably hack together your own context menu if you REALLY felt inclined :) $\endgroup$ – tkott Mar 3 '12 at 23:11
  • $\begingroup$ If you use, in some dynamic module, an event handler of just "KeyDown" without naming any key, you'll get an event for ordinary keypresses like [Q] or [space] but (at least under Linux) not for the Menu key. $\endgroup$ – celtschk Mar 9 '12 at 9:13

I tried AutoHotKey with this code and it worked:

#IfWinActive, ahk_class NotebookFrame
AppsKey::Send {Click right}
  • 1
    $\begingroup$ Hi, welcome to Mathematica! Could you please expand on your answer and explain what the next steps are in order for the OP to use the key as they desired in mathematica? $\endgroup$ – rm -rf Mar 15 '12 at 1:07
  • 2
    $\begingroup$ The problem with this is that a right-click is simulated at the position of the mouse pointer, not on whatever is selected in the Mathematica front end. $\endgroup$ – Andrew Mar 15 '12 at 2:04

In the past I had some success interfacing Mathematica with Wiimotes using the programs PPJoy and GlovePIE. GlovePIE took care of the Wii stuff and PPJoy has hooks for it. PPJoy can be used to let Windows believe it's connected to a joystick. In that way even a keyboard can be turned into a joystick, with buttons and all.

The nice thing is, Mathematica has access to most game devices (including this virtual one) using the ControllerState function. So, if you get PPJoy to install it should be relatively easy to let a certain button activate something. We would still need to find a FrontEnd token for this specific event. A long list may be found here. I don't believe it's in there.

PPJoy worked flawless on my old win XP laptop I used when working with this setup, but on win7 there appears to be problems. A workaround can be found here or here.


Your Answer

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

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