fix(core): update
This commit is contained in:
parent
ca52d06c60
commit
c5e75419b3
@ -144,6 +144,16 @@ export class Keyboard {
|
|||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public triggerKeyPress(keysArg: Key[]) {
|
||||||
|
for (const key of keysArg) {
|
||||||
|
this.pressedKeys.add(key);
|
||||||
|
}
|
||||||
|
this.checkMatchingKeyboardSubjects();
|
||||||
|
for (const key of keysArg) {
|
||||||
|
this.pressedKeys.delete(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public startListening() {
|
public startListening() {
|
||||||
this.domNode.addEventListener('keydown', this.handleKeyDown);
|
this.domNode.addEventListener('keydown', this.handleKeyDown);
|
||||||
this.domNode.addEventListener('keyup', this.handleKeyUp);
|
this.domNode.addEventListener('keyup', this.handleKeyUp);
|
||||||
@ -162,13 +172,16 @@ export class Keyboard {
|
|||||||
|
|
||||||
private handleKeyDown = (event: KeyboardEvent) => {
|
private handleKeyDown = (event: KeyboardEvent) => {
|
||||||
this.pressedKeys.add(event.keyCode);
|
this.pressedKeys.add(event.keyCode);
|
||||||
|
this.checkMatchingKeyboardSubjects(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
private checkMatchingKeyboardSubjects(payloadArg?) {
|
||||||
this.mapCombosToHandlers.forEach((subjectArg, keysArg) => {
|
this.mapCombosToHandlers.forEach((subjectArg, keysArg) => {
|
||||||
if (this.areAllKeysPressed(keysArg)) {
|
if (this.areAllKeysPressed(keysArg)) {
|
||||||
subjectArg.next(event);
|
subjectArg.next(payloadArg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
private handleKeyUp = (event: KeyboardEvent) => {
|
private handleKeyUp = (event: KeyboardEvent) => {
|
||||||
this.pressedKeys.delete(event.keyCode);
|
this.pressedKeys.delete(event.keyCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user