Skip to content

Commit

Permalink
feat: modify filter function on readOnly element (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyjjqq94 authored and jaywcjlove committed May 9, 2019
1 parent 9d6e2b9 commit 8e2c1b5
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 10 deletions.
10 changes: 8 additions & 2 deletions dist/hotkeys.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,19 @@ function getScope() {
function getPressedKeyCodes() {
return _downKeys.slice(0);
} // 表单控件控件判断 返回 Boolean
// hotkey is effective only when filter return true


function filter(event) {
var target = event.target || event.srcElement;
var tagName = target.tagName; // 忽略这些情况下快捷键无效
var tagName = target.tagName;
var flag = true; // ignore: isContentEditable === 'true', <input> and <textarea> when readOnly state is false, <select>

return !(tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA' || target.isContentEditable);
if (target.isContentEditable || tagName === 'TEXTAREA' || (tagName === 'INPUT' || tagName === 'TEXTAREA') && !target.readOnly) {
flag = false;
}

return flag;
} // 判断摁下的键是否为某个键,返回true或者false


Expand Down
2 changes: 1 addition & 1 deletion dist/hotkeys.common.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions dist/hotkeys.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,19 @@ function getScope() {
function getPressedKeyCodes() {
return _downKeys.slice(0);
} // 表单控件控件判断 返回 Boolean
// hotkey is effective only when filter return true


function filter(event) {
var target = event.target || event.srcElement;
var tagName = target.tagName; // 忽略这些情况下快捷键无效
var tagName = target.tagName;
var flag = true; // ignore: isContentEditable === 'true', <input> and <textarea> when readOnly state is false, <select>

return !(tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA' || target.isContentEditable);
if (target.isContentEditable || tagName === 'TEXTAREA' || (tagName === 'INPUT' || tagName === 'TEXTAREA') && !target.readOnly) {
flag = false;
}

return flag;
} // 判断摁下的键是否为某个键,返回true或者false


Expand Down
10 changes: 8 additions & 2 deletions dist/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,19 @@
function getPressedKeyCodes() {
return _downKeys.slice(0);
} // 表单控件控件判断 返回 Boolean
// hotkey is effective only when filter return true


function filter(event) {
var target = event.target || event.srcElement;
var tagName = target.tagName; // 忽略这些情况下快捷键无效
var tagName = target.tagName;
var flag = true; // ignore: isContentEditable === 'true', <input> and <textarea> when readOnly state is false, <select>

return !(tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA' || target.isContentEditable);
if (target.isContentEditable || tagName === 'TEXTAREA' || (tagName === 'INPUT' || tagName === 'TEXTAREA') && !target.readOnly) {
flag = false;
}

return flag;
} // 判断摁下的键是否为某个键,返回true或者false


Expand Down
Loading

0 comments on commit 8e2c1b5

Please sign in to comment.