Improved web PPT keyhook
parent
b2923025c1
commit
005e26024a
|
@ -2,6 +2,8 @@
|
||||||
* **24.11.19**
|
* **24.11.19**
|
||||||
- Fixed several bugs within the permission editor
|
- Fixed several bugs within the permission editor
|
||||||
- Hide senseless permissions (disableable via options)
|
- Hide senseless permissions (disableable via options)
|
||||||
|
- Mute system sounds by default if the output has been muted
|
||||||
|
- Improved PPT handler for the web client [#73](https://github.com/TeaSpeak/TeaWeb/issues/73)
|
||||||
|
|
||||||
* **06.10.19**
|
* **06.10.19**
|
||||||
- Added the possibility to connect within an already running TeaWeb instance
|
- Added the possibility to connect within an already running TeaWeb instance
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace ppt {
|
||||||
}
|
}
|
||||||
|
|
||||||
let key_listener: ((_: KeyEvent) => any)[] = [];
|
let key_listener: ((_: KeyEvent) => any)[] = [];
|
||||||
|
|
||||||
function listener_key(type: EventType, event: KeyboardEvent) {
|
function listener_key(type: EventType, event: KeyboardEvent) {
|
||||||
const key_event = {
|
const key_event = {
|
||||||
type: type,
|
type: type,
|
||||||
|
@ -66,9 +66,7 @@ namespace ppt {
|
||||||
let key_hooks: KeyHook[] = [];
|
let key_hooks: KeyHook[] = [];
|
||||||
|
|
||||||
interface CurrentState {
|
interface CurrentState {
|
||||||
event: KeyEvent;
|
keys: {[code: string]:KeyEvent};
|
||||||
code: string;
|
|
||||||
|
|
||||||
special: { [key:number]:boolean };
|
special: { [key:number]:boolean };
|
||||||
}
|
}
|
||||||
let current_state: CurrentState = {
|
let current_state: CurrentState = {
|
||||||
|
@ -83,8 +81,8 @@ namespace ppt {
|
||||||
current_state.special[SpecialKey.SHIFT] = false;
|
current_state.special[SpecialKey.SHIFT] = false;
|
||||||
current_state.special[SpecialKey.WINDOWS] = false;
|
current_state.special[SpecialKey.WINDOWS] = false;
|
||||||
|
|
||||||
current_state.code = undefined;
|
for(const code of Object.keys(current_state.keys))
|
||||||
current_state.event = undefined;
|
delete current_state[code];
|
||||||
|
|
||||||
for(const hook of key_hooks_active)
|
for(const hook of key_hooks_active)
|
||||||
hook.callback_release();
|
hook.callback_release();
|
||||||
|
@ -103,15 +101,12 @@ namespace ppt {
|
||||||
current_state.special[SpecialKey.SHIFT] = event.key_shift;
|
current_state.special[SpecialKey.SHIFT] = event.key_shift;
|
||||||
current_state.special[SpecialKey.WINDOWS] = event.key_windows;
|
current_state.special[SpecialKey.WINDOWS] = event.key_windows;
|
||||||
|
|
||||||
current_state.code = undefined;
|
current_state[event.key_code] = undefined;
|
||||||
current_state.event = undefined;
|
|
||||||
|
|
||||||
if(event.type == EventType.KEY_PRESS) {
|
if(event.type == EventType.KEY_PRESS) {
|
||||||
current_state.event = event;
|
current_state[event.key_code] = event;
|
||||||
current_state.code = event.key_code;
|
|
||||||
|
|
||||||
for(const hook of key_hooks) {
|
for(const hook of key_hooks) {
|
||||||
if(hook.key_code && hook.key_code != event.key_code) continue;
|
if(hook.key_code !== event.key_code) continue;
|
||||||
if(hook.key_alt != event.key_alt) continue;
|
if(hook.key_alt != event.key_alt) continue;
|
||||||
if(hook.key_ctrl != event.key_ctrl) continue;
|
if(hook.key_ctrl != event.key_ctrl) continue;
|
||||||
if(hook.key_shift != event.key_shift) continue;
|
if(hook.key_shift != event.key_shift) continue;
|
||||||
|
@ -126,11 +121,18 @@ namespace ppt {
|
||||||
}
|
}
|
||||||
|
|
||||||
//We have a new situation
|
//We have a new situation
|
||||||
for(const hook of old_hooks)
|
for(const hook of old_hooks) {
|
||||||
if(hook.callback_release) {
|
//Do not test for meta key states because they could differ in a key release event
|
||||||
hook.callback_release();
|
if(hook.key_code === event.key_code) {
|
||||||
log.trace(LogCategory.GENERAL, tr("Trigger key release for %o!"), hook);
|
if(hook.callback_release) {
|
||||||
|
hook.callback_release();
|
||||||
|
log.trace(LogCategory.GENERAL, tr("Trigger key release for %o!"), hook);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("No match: %o - %o", hook.key_code, event.key_code);
|
||||||
|
new_hooks.push(hook);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
key_hooks_active = new_hooks;
|
key_hooks_active = new_hooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue