event.keyCode doesn't work in Firefox
This commit is contained in:
parent
a2943852a7
commit
6f74cb8b29
4
edit.js
4
edit.js
|
@ -1783,7 +1783,9 @@ function showHelp(title, text) {
|
||||||
return div;
|
return div;
|
||||||
|
|
||||||
function closeHelp(e) {
|
function closeHelp(e) {
|
||||||
if (!e || e.type == "click" || (e.keyCode == 27 && !e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey)) {
|
if (!e
|
||||||
|
|| e.type == "click"
|
||||||
|
|| ((e.keyCode || e.which) == 27 && !e.altKey && !e.ctrlKey && !e.shiftKey && !e.metaKey)) {
|
||||||
div.style.display = "";
|
div.style.display = "";
|
||||||
document.querySelector(".contents").innerHTML = "";
|
document.querySelector(".contents").innerHTML = "";
|
||||||
document.removeEventListener("keydown", closeHelp);
|
document.removeEventListener("keydown", closeHelp);
|
||||||
|
|
|
@ -59,7 +59,7 @@ function initGlobalEvents() {
|
||||||
|
|
||||||
// focus search field on / key
|
// focus search field on / key
|
||||||
document.onkeypress = event => {
|
document.onkeypress = event => {
|
||||||
if (event.keyCode == 47
|
if ((event.keyCode || event.which) == 47
|
||||||
&& !event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey
|
&& !event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey
|
||||||
&& !event.target.matches('[type="text"], [type="search"]')) {
|
&& !event.target.matches('[type="text"], [type="search"]')) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
@ -28,10 +28,11 @@ function messageBox({
|
||||||
resolveWith({button: this.buttonIndex});
|
resolveWith({button: this.buttonIndex});
|
||||||
},
|
},
|
||||||
key(event) {
|
key(event) {
|
||||||
|
const keyCode = event.keyCode || event.which;
|
||||||
if (!event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey
|
if (!event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey
|
||||||
&& (event.keyCode == 13 || event.keyCode == 27)) {
|
&& (keyCode == 13 || keyCode == 27)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
resolveWith(event.keyCode == 13 ? {enter: true} : {esc: true});
|
resolveWith(keyCode == 13 ? {enter: true} : {esc: true});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scroll() {
|
scroll() {
|
||||||
|
|
5
popup.js
5
popup.js
|
@ -275,10 +275,11 @@ Object.assign(handleEvent, {
|
||||||
$('[data-cmd="ok"]', box).onclick = () => confirm(true);
|
$('[data-cmd="ok"]', box).onclick = () => confirm(true);
|
||||||
$('[data-cmd="cancel"]', box).onclick = () => confirm(false);
|
$('[data-cmd="cancel"]', box).onclick = () => confirm(false);
|
||||||
window.onkeydown = event => {
|
window.onkeydown = event => {
|
||||||
|
const keyCode = event.keyCode || event.which;
|
||||||
if (!event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey
|
if (!event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey
|
||||||
&& (event.keyCode == 13 || event.keyCode == 27)) {
|
&& (keyCode == 13 || keyCode == 27)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
confirm(event.keyCode == 13);
|
confirm(keyCode == 13);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function confirm(ok) {
|
function confirm(ok) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user