Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Expose method to bind to additional elements #235

Closed
Craga89 opened this issue Nov 11, 2014 · 4 comments
Closed

[Enhancement] Expose method to bind to additional elements #235

Craga89 opened this issue Nov 11, 2014 · 4 comments

Comments

@Craga89
Copy link

Craga89 commented Nov 11, 2014

We can add a newly exposed method to support the use case of handling events within <iframe> and similar elements that don't bubble their events? Such as:

// Exposed on the `Mousetrap` object
bindEvents: function(el) {
    _addEvent(el, 'keypress', _handleKeyEvent);
    _addEvent(el, 'keydown', _handleKeyEvent);
    _addEvent(el, 'keyup', _handleKeyEvent);
}
// Proxy events from our <iframe> element to Mousetrap
var iframeDocument = document.querySelector('iframe').contentDocument;
Moustrap.bind( iframeDocument );

See #107

@mightyiam
Copy link

My fork, https://www.npmjs.org/package/combokeys, has this feature:

var combokeys = new Combokeys(document.getElementById("someIframeOrSomething"));

And then your combokeys instance is bound to that element.

@rtorcato
Copy link

mighty lam can your comborkeys package be used without requirejs?

@mightyiam
Copy link

@rtorcato you can use Browserify to make a UMD out of it, with Browserify's --standalone option.

@rtorcato
Copy link

ok thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants