ui: use event.key instead of event.keyCode for various keybindings

This commit is contained in:
jean-emmanuel 2025-02-22 10:04:28 +01:00
parent 107ca1d295
commit c554a23c99
10 changed files with 23 additions and 23 deletions

View file

@ -90,8 +90,8 @@ class Input extends Canvas {
}
this.input.addEventListener('keydown', (e)=>{
if (e.keyCode === 13) this.blur() // enter
else if (e.keyCode === 27) this.blur(false) // esc
if (e.key == 'Enter') this.blur()
else if (e.key == 'Escape') this.blur(false)
else if (asYouType) {
setTimeout(()=>{
this.inputChange()

View file

@ -49,12 +49,12 @@ class TextArea extends Widget {
}, {element: this.input})
this.input.addEventListener('keydown', (e)=>{
if (e.keyCode === 13 && !e.shiftKey) {
if (e.key == 'Enter' && !e.shiftKey) {
// enter
e.preventDefault()
this.blur()
}
else if (e.keyCode === 27) {
else if (e.key == 'Escape') {
// esc
this.blur(false)
this.input.value = this.value

View file

@ -123,7 +123,7 @@ class Modal extends Panel {
this.escapeKeyHandler = ((e)=>{
if (e.keyCode==27) this.setValue(0, {sync:true, send:true})
if (e.key == 'Escape') this.setValue(0, {sync:true, send:true})
}).bind(this)
this.value = 0