Open crittermike opened 12 years ago
The element's isContentEditable
property is possibly a better source of information, though I don't know how widely supported it is.
key.filter = function(event) {
var el = event.target || event.srcElement;
return !(el.isContentEditable || el.tagName == 'INPUT' ||
el.tagName == 'SELECT' || el.tagName == 'TEXTAREA');
}
+1
Would you accept a pull request for this change, @madrobby?
:+1: is there any reason this has been open for a year and half? I'm happy to PR if that's all it needs.
@ajb not everyone needs this, that's why the filter function is easily overridable. I'd merge a PR with extensive tests tho. It needs detection of the browser supports isContentEditable
, I have no idea about how widespread support is. Remember that kemaster should work on older browsers.
Thanks -- to your credit, key.filter
is very-well documented :grinning:. I'll see if I can whip something together...
@madrobby Awesome library so far. :+1: to add contenteditable
elements in the default filter.
I just overrode key.filter() to also ignore keypresses when the current element is contenteditable, using this code:
I'm not sure if that's the best way to implement it, but it seems like this would be a good default, no?