0

I want to modify the contents of event objects in a userscript.

Specifically, I want to do this simple operation:

if (event.metaKey) event.ctrlKey = true;

i.e., If my script is running on a page that uses jQuery, events that are used by that instance of jQuery will register a cmd key press as a ctrl key press.

Is what I'm thinking of even possible? If so, how can I redefine how jQuery creates event objects?

Community
  • 1
  • 1
fredley
  • 32,953
  • 42
  • 145
  • 236
  • You may be able to use the hotkeys plugin - http://stackoverflow.com/questions/593602/keyboard-shortcuts-with-jquery – Jay Blanchard Feb 07 '14 at 17:39
  • If the event listeners are jQuery-based, you should be able to capture and retrigger. You will need to inject the code that does this. Beware that many (¿most?) [native event handlers ignore artificial key events](http://stackoverflow.com/a/13946504/331508). – Brock Adams Feb 07 '14 at 20:42

0 Answers0