keymaster icon indicating copy to clipboard operation
keymaster copied to clipboard

Customizing window and document

Open denis-sokolov opened this issue 11 years ago • 3 comments

Currently the library adds event handlers using global variables. Would you be open to modifying or accepting a pull request to allow customizing the window by passing it in as an argument?

denis-sokolov avatar Jul 12 '14 20:07 denis-sokolov

Any update on this?

moroshko avatar Apr 16 '15 07:04 moroshko

Is key.noConflict not enough? What's the use case here and how would you imagine at this to work (any patch should be backwards-compatible with earlier versions of keymaster).

madrobby avatar Apr 16 '15 10:04 madrobby

Sorry, I have missed the notification originally.

The use case is using various window objects, for example in jsdom environment during various testing.

The simplest API for that would be to prepend a window parameter as the first parameter:

key(window, 'a', function(){ alert('you pressed a!') });
key(window, 'ctrl+r', function(){ alert('stopped reload!'); return false });
key(window, '⌘+r, ctrl+r', function(){ });

If the parameter has not been passed, take it from the global context.

denis-sokolov avatar Jun 05 '15 09:06 denis-sokolov