Custom keyboard shortcuts: only in certain context.action (e.g. "view")

I’d like to add a keyboard-shortcut to trigger an action by adding a JavaScript StyleSheet Extension. How can I make sure, this only fires in view-mode. The following code doesn’t work. The context seems to always be jsx.

#if ( $context.action == "view" )
shortcut.add("Alt+w", function() { window.open(document.getElementById("my-next").href, "_self") });
#end

(Originally asked within this thread)