Fix browser hotkeys not working

CTRL+C for copying text
CTRL+F for focusing search box above chat log
CTRL+SHIFT+I for inspector tools
This commit is contained in:
Stubenhocker1399
2019-10-06 14:07:33 +02:00
parent b677f17bc7
commit 8ed9db1334
3 changed files with 15 additions and 3 deletions
+11 -1
View File
@@ -175,6 +175,7 @@ export class PonyTownGame implements Game {
shadowColor = SHADOW_COLOR;
onChat = new Subject<void>();
onToggleChat = new Subject<void>();
onSearch = new Subject<void>();
onCommand = new Subject<void>();
onCancel = () => false;
onClock = new BehaviorSubject<string>('');
@@ -458,7 +459,16 @@ export class PonyTownGame implements Game {
interact(this, this.input.isPressed(Key.SHIFT));
});
this.input.onPressed([Key.KEY_X, Key.GAMEPAD_BUTTON_DOWN], () => downAction(this));
this.input.onPressed([Key.KEY_C, Key.GAMEPAD_BUTTON_UP], () => upAction(this));
this.input.onPressed([Key.KEY_C, Key.GAMEPAD_BUTTON_UP], () => {
if (!this.input.isPressed(Key.CTRL)) {
upAction(this);
}
});
this.input.onPressed(Key.KEY_F, () => {
if (this.input.isPressed(Key.CTRL)) {
this.onSearch.next();
}
});
this.input.onPressed(Key.F2, () => {
if (!this.settings.browser.disableFKeys) {
this.hideText = !this.hideText;
+1 -1
View File
@@ -9,7 +9,7 @@ function isKeyEventInvalid(e: KeyboardEvent) {
}
function allowKey(key: number) {
return key === Key.ESCAPE || key === Key.F5 || key === Key.F12 || key === Key.F11 || key === Key.TAB;
return key === Key.ESCAPE || key === Key.F5 || key === Key.F12 || key === Key.F11 || key === Key.TAB || key === Key.KEY_C || key === Key.KEY_I;
}
function fixKeyCode(key: number) {
@@ -281,6 +281,9 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
updateEntityId(this.party, update.old, update.new);
updateEntityId(this.whisper, update.old, update.new);
}),
this.game.onSearch.subscribe(() => {
this.focus();
}),
);
}
get linesElement() {
@@ -457,7 +460,6 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
let value = this.filterInput.nativeElement.value;
if (!value) {
this.clearTimeOutAutoClear();
this.unFocus();
this.filterChatLogLines('', false);
return;
} else {