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.

-
Actually I don't recall ever having used this button ;-) –  Sjoerd C. de Vries Mar 3 '12 at 23:31
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? –  Rojo Mar 4 '12 at 0:18
Same issue occurs on Linux. –  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:

k=0;
SetOptions[$FrontEndSession, 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: FrontEndTokenExecute["CellContextDialog"]  This automatically launches the front end dialog that is mentioned. A full list of Front End Tokens is available here. Putting things together: SetOptions[$FrontEndSession,
FrontEndEventActions -> {{"KeyDown", "q"} :> (++k;
FrontEndTokenExecute["CellContextDialog"]),
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!

-
Something like 'a FrontEndToken corresponding to the "Right Click" / "Contxt" ' menu would be crucial. –  Andrew MacFie Mar 3 '12 at 22:59
@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 :) –  tkott Mar 3 '12 at 23:11
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. –  celtschk Mar 9 '12 at 9:13

I tried AutoHotKey with this code and it worked:

#IfWinActive, ahk_class NotebookFrame
AppsKey::Send {Click right}
#IfWinActive

-
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? –  rm -rf Mar 15 '12 at 1:07
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. –  Andrew MacFie 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.

-