From 48a5d45faaa59c75b018c85a33e51374d1ab9734 Mon Sep 17 00:00:00 2001 From: jojohoch <joachim.hoch@iqb.hu-berlin.de> Date: Wed, 23 Aug 2023 09:48:29 +0200 Subject: [PATCH] [player] Add additional keys of preset layout to custom keyboard --- .../components/keyboard/keyboard.component.ts | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/projects/player/modules/key-input/components/keyboard/keyboard.component.ts b/projects/player/modules/key-input/components/keyboard/keyboard.component.ts index 6aa18268c..d67646172 100644 --- a/projects/player/modules/key-input/components/keyboard/keyboard.component.ts +++ b/projects/player/modules/key-input/components/keyboard/keyboard.component.ts @@ -23,10 +23,7 @@ export class KeyboardComponent implements OnInit { ngOnInit(): void { if (this.preset && this.addInputAssistanceToKeyboard) { - this.additionalRow = KeyLayout - .get(this.preset, this.customKeys).default - .flat() - .filter(key => key.length === 1); + this.additionalRow = this.getAdditionalRowWithAdditionalKeys('default'); } } @@ -60,19 +57,20 @@ export class KeyboardComponent implements OnInit { this.shift = !this.shift; this.rows = this.shift ? this.layout.shift : this.layout.default; if (this.preset && this.addInputAssistanceToKeyboard) { - this.additionalRow = this.shift && - KeyLayout - .get(this.preset, this.customKeys).shift - .flat() - .filter(key => key.length === 1).length ? - KeyLayout - .get(this.preset, this.customKeys).shift - .flat() - .filter(key => key.length === 1) : - KeyLayout - .get(this.preset, this.customKeys).default - .flat() - .filter(key => key.length === 1); + this.additionalRow = this.shift && this.getAdditionalRow('shift').length > 0 ? + this.getAdditionalRowWithAdditionalKeys('shift') : + this.getAdditionalRowWithAdditionalKeys('default'); } } + + private getAdditionalRow(layoutKey: 'default' | 'shift' | 'additional'): string[] { + return KeyLayout + .get(this.preset, this.customKeys)[layoutKey] + .flat() + .filter(key => key.length === 1); + } + + private getAdditionalRowWithAdditionalKeys(layoutKey: 'default' | 'shift'): string[] { + return [...this.getAdditionalRow(layoutKey), ...this.getAdditionalRow('additional')]; + } } -- GitLab