Skip to content

Instantly share code, notes, and snippets.

@smmoosavi
Last active August 29, 2015 14:12
Show Gist options
  • Save smmoosavi/2b937a501cdeacc5fd4a to your computer and use it in GitHub Desktop.
Save smmoosavi/2b937a501cdeacc5fd4a to your computer and use it in GitHub Desktop.
change keymaster.js lib behavior with inputs
var keymaster = key.noConflict();
(function(){
var _lastScope = keymaster.getScope();
var _inputScope = false;
keymaster.filter = function () {
var tagName = (event.target || event.srcElement).tagName;
if (tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA') {
if (!_inputScope) {
_inputScope = true;
_lastScope = keymaster.getScope();
}
keymaster.setScope('input');
} else if (_inputScope) {
_inputScope = false;
keymaster.setScope(_lastScope);
}
return true;
};
keymaster.getLastScope = function(){
return _lastScope;
};
keymaster.isInputScope = function(){
return _inputScope;
};
})();
#!/usr/bin/env bash
cp bower_components/keymaster/keymaster.js my/keymaster.js
cat keymaster-patch.js >> my/keymaster.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment