As mentioned, it needs to be a ‘Gig Script’ to be able to detect the keyboard keystrokes. But the flip-side is that you can’t control widgets directly in a gig script (only in rackspace scripts).
The way around this is to have the gig script generate a midi message, which is then ‘midi learned’ by the widget.
This is the basic script, and an example gig file.
Toggle Widget via Keystroke.gig (25.8 KB)
// Generate a MIDI message when pressing a key on the keyboard
On Keystroke matching "m" Description "Toggle Widget"
InjectMidiEvent("Local GP Port", MakeControlChangeMessage(80, 127))
End