ui: use event.key instead of event.keyCode for various keybindings
This commit is contained in:
parent
107ca1d295
commit
c554a23c99
10 changed files with 23 additions and 23 deletions
|
|
@ -40,7 +40,7 @@ class CodeEditor {
|
|||
this.closeKey = ((e)=>{
|
||||
// this handler may remain dangling if closing with ctrl+enter
|
||||
// we ignore this as it has no effect
|
||||
if (e.keyCode !== 27) return
|
||||
if (e.key != 'Escape') return
|
||||
this.field.classList.remove('fullscreen')
|
||||
this.editor.setOptions({maxLines: 30})
|
||||
this.editor.fullscreen = false
|
||||
|
|
@ -52,7 +52,7 @@ class CodeEditor {
|
|||
|
||||
this.closeClick = ((e)=>{
|
||||
if (e.target === this.field) {
|
||||
this.closeKey({keyCode: 27})
|
||||
this.closeKey({key: 'Escape'})
|
||||
}
|
||||
}).bind(this)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ class ColorPicker extends UiWidget {
|
|||
this.opened = 0
|
||||
|
||||
this.escKeyHandler = ((e)=>{
|
||||
if (e.keyCode==27) this.close()
|
||||
if (e.key == 'Escape') this.close()
|
||||
}).bind(this)
|
||||
|
||||
this.enterKeyHandler = ((e)=>{
|
||||
if (e.keyCode == 13) this.confirm()
|
||||
if (e.key == 'Enter') this.confirm()
|
||||
}).bind(this)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,10 +69,10 @@ class UiConsole extends UiSidePanel {
|
|||
this.widget.hash = 'CONSOLE'
|
||||
|
||||
this.input.addEventListener('keydown', (event)=>{
|
||||
if (event.keyCode === 13 && !event.shiftKey) {
|
||||
if (event.key === 'Enter' && !event.shiftKey) {
|
||||
event.preventDefault()
|
||||
this.inputValidate()
|
||||
} else if (event.keyCode === 38) {
|
||||
} else if (event.key == 'ArrowUp') {
|
||||
if (this.cursor < this.history.length - 1) {
|
||||
|
||||
if (this.input.value.substr(0, this.input.selectionStart).split('\n').length !== 1) return
|
||||
|
|
@ -81,7 +81,7 @@ class UiConsole extends UiSidePanel {
|
|||
this.input.value = this.history[this.cursor]
|
||||
event.preventDefault()
|
||||
}
|
||||
} else if (event.keyCode === 40) {
|
||||
} else if (event.key == 'ArrowDown') {
|
||||
if (this.cursor > 0) {
|
||||
var nLines = this.input.value.split('\n').length
|
||||
if (this.input.value.substr(0, this.input.selectionStart).split('\n').length !== nLines) return
|
||||
|
|
@ -90,7 +90,7 @@ class UiConsole extends UiSidePanel {
|
|||
this.input.value = this.history[this.cursor]
|
||||
event.preventDefault()
|
||||
}
|
||||
} else if (event.keyCode === 9 && this.input.value !== '') {
|
||||
} else if (event.key == 'DOM_VK_TAB' && this.input.value !== '') {
|
||||
var cur = this.input.selectionStart,
|
||||
val = this.input.value
|
||||
this.input.value = val.slice(0, cur) + ' ' + val.slice(cur)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ module.exports = function UiFilebrowser(options, callback) {
|
|||
|
||||
function keyDownHandler(e){
|
||||
|
||||
if (e.keyCode === 13) {
|
||||
if (e.key == 'Enter') {
|
||||
if (save) {
|
||||
document.addEventListener('keyup', keyUpHandler)
|
||||
} else {
|
||||
|
|
@ -103,7 +103,7 @@ module.exports = function UiFilebrowser(options, callback) {
|
|||
}
|
||||
} else if (e.target === saveInput) {
|
||||
return
|
||||
} else if (e.keyCode === 8) {
|
||||
} else if (e.key == 'DOM_VK_BACK_SPACE') {
|
||||
list.childNodes[0].firstElementChild.checked = true
|
||||
submit()
|
||||
} else if (e.key.length === 1) {
|
||||
|
|
@ -131,7 +131,7 @@ module.exports = function UiFilebrowser(options, callback) {
|
|||
}
|
||||
function keyUpHandler(e){
|
||||
|
||||
if (e.keyCode === 13) {
|
||||
if (e.key == 'Enter') {
|
||||
setTimeout(submit, 100)
|
||||
document.removeEventListener('keyup', keyUpHandler)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ class UiInspector extends UiWidget {
|
|||
|
||||
if (event.target.tagName === 'TEXTAREA') {
|
||||
|
||||
if (event.keyCode === 13 &&
|
||||
if (event.key == 'Enter' &&
|
||||
((!event.shiftKey && !event.target._ace) ||
|
||||
(event[codeEditorModKey] && event.target._ace))
|
||||
) {
|
||||
|
|
@ -338,7 +338,7 @@ class UiInspector extends UiWidget {
|
|||
event.preventDefault()
|
||||
DOM.dispatchEvent(event.target, 'change')
|
||||
|
||||
} else if (event.keyCode === 27) {
|
||||
} else if (event.key == 'Escape') {
|
||||
|
||||
event.preventDefault()
|
||||
event.target.value = event.target.textContent
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ class UiModal extends UiWidget {
|
|||
|
||||
if (this.escKey) {
|
||||
this.escKeyHandler = ((e)=>{
|
||||
if (e.keyCode==27) this.close()
|
||||
if (e.key == 'Escape') this.close()
|
||||
}).bind(this)
|
||||
}
|
||||
|
||||
if (this.enterKey) {
|
||||
this.enterKeyHandler = ((e)=>{
|
||||
if (e.keyCode == 13) this.enterKey.call(this, e)
|
||||
if (e.key == 'Enter') this.enterKey.call(this, e)
|
||||
}).bind(this)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ class Zoom extends EventEmitter {
|
|||
document.addEventListener('keydown', (event)=>{
|
||||
if (event[mod]) {
|
||||
|
||||
if (event.keyCode == 96 || event.keyCode == 48) {
|
||||
if (event.key == 'DOM_VK_0' || event.key == 'Numpad0') {
|
||||
this.setGlobalZoom(INITIALZOOM)
|
||||
this.setLocalZoom(1)
|
||||
}
|
||||
else if (event.keyCode == 107 || event.keyCode == 109) {
|
||||
this.setGlobalZoom((event.keyCode == 107 ? 0.1 : -0.1) + PXSCALE)
|
||||
else if (event.key == '+' || event.key == '-') {
|
||||
this.setGlobalZoom((event.key == '+' ? 0.1 : -0.1) + PXSCALE)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue