Просмотр исходного кода

Add vim and alternate keybindings

Thomas Dy 4 лет назад
Родитель
Сommit
121e2113cb
2 измененных файлов с 9 добавлено и 9 удалено
  1. 5 5
      src/game/select.ts
  2. 4 4
      src/game/typing.ts

+ 5 - 5
src/game/select.ts

@@ -127,9 +127,9 @@ namespace game {
     }
 
     handleInput(key: string): void {
-      if (key === 'ArrowLeft') {
+      if (key === 'ArrowLeft' || key === 'h') {
         this.scroll(-1);
-      } else if (key === 'ArrowRight') {
+      } else if (key === 'ArrowRight' || key === 'l') {
         this.scroll(1);
       }
     }
@@ -179,15 +179,15 @@ namespace game {
     }
 
     handleInput(key: string): void {
-      if (key === 'ArrowUp') {
+      if (key === 'ArrowUp' || key === 'k') {
         this.scroll(-1);
-      } else if (key === 'ArrowDown') {
+      } else if (key === 'ArrowDown' || key === 'j') {
         this.scroll(1);
       } else if (key === 'PageUp') {
         this.scroll(-5);
       } else if (key === 'PageDown') {
         this.scroll(5);
-      } else if (key === ' ') {
+      } else if (key === ' ' || key === 'Enter') {
         this.choose();
       }
     }

+ 4 - 4
src/game/typing.ts

@@ -144,9 +144,9 @@ namespace game {
     }
 
     handleInput(key: string): void {
-      if (key == 'Escape') {
+      if (key === 'Escape' || key === 'Backspace') {
         this.context.switchScreen(null);
-      } else if (this.isReady && key === ' ') {
+      } else if (this.isReady && (key === ' ' || key === 'Enter')) {
         this.context.switchScreen(new TypingPlayingScreen(this.context));
       }
     }
@@ -263,7 +263,7 @@ namespace game {
     }
 
     handleInput(key: string): void {
-      if (key === 'Escape') {
+      if (key === 'Escape' || key === 'Backspace') {
         this.finish();
       } else if (!this.isWaiting) {
         if (this.inputState !== null && /^[-_ a-z]$/.test(key)) {
@@ -344,7 +344,7 @@ namespace game {
     enter(): void {}
 
     handleInput(key: string): void {
-      if (key === ' ' || key === 'Escape') {
+      if (key === ' ' || key === 'Enter' || key === 'Escape' || key === 'Backspace') {
         this.context.switchScreen(null);
       }
     }