mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
log active keys + onBlur
This commit is contained in:
parent
14caa1fba8
commit
52ee737276
@ -161,6 +161,7 @@
|
|||||||
private observer = new ResizeObserver(this.onResise.bind(this))
|
private observer = new ResizeObserver(this.onResise.bind(this))
|
||||||
private focused = false
|
private focused = false
|
||||||
private fullscreen = false
|
private fullscreen = false
|
||||||
|
private activeKeys: any = {}
|
||||||
|
|
||||||
get admin() {
|
get admin() {
|
||||||
return this.$accessor.user.admin
|
return this.$accessor.user.admin
|
||||||
@ -333,12 +334,14 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
document.addEventListener('focusin', this.onFocus.bind(this))
|
document.addEventListener('focusin', this.onFocus.bind(this))
|
||||||
|
document.addEventListener('focusout', this.onBlur.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.observer.disconnect()
|
this.observer.disconnect()
|
||||||
this.$accessor.video.setPlayable(false)
|
this.$accessor.video.setPlayable(false)
|
||||||
document.removeEventListener('focusin', this.onFocus.bind(this))
|
document.removeEventListener('focusin', this.onFocus.bind(this))
|
||||||
|
document.removeEventListener('focusout', this.onBlur.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
play() {
|
play() {
|
||||||
@ -401,6 +404,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onBlur() {
|
||||||
|
if (!this.focused || !this.hosting || this.locked) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let keys = Object.keys(this.activeKeys)
|
||||||
|
for(let key of keys) {
|
||||||
|
this.$client.sendData('keyup', { key })
|
||||||
|
delete this.activeKeys[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMousePos(e: MouseEvent) {
|
onMousePos(e: MouseEvent) {
|
||||||
const { w, h } = this.$accessor.video.resolution
|
const { w, h } = this.$accessor.video.resolution
|
||||||
const rect = this._overlay.getBoundingClientRect()
|
const rect = this._overlay.getBoundingClientRect()
|
||||||
@ -486,7 +501,9 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$client.sendData('keydown', { key: this.getCode(e) })
|
let key = this.getCode(e)
|
||||||
|
this.$client.sendData('keydown', { key })
|
||||||
|
this.activeKeys[key] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
onKeyUp(e: KeyboardEvent) {
|
onKeyUp(e: KeyboardEvent) {
|
||||||
@ -494,7 +511,9 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$client.sendData('keyup', { key: this.getCode(e) })
|
let key = this.getCode(e)
|
||||||
|
this.$client.sendData('keyup', { key })
|
||||||
|
delete this.activeKeys[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
onResise() {
|
onResise() {
|
||||||
|
Loading…
Reference in New Issue
Block a user