浏览代码

Restrict alphabet for input and kana

Thomas Dy 7 年之前
父节点
当前提交
d475ccf7c0
共有 2 个文件被更改,包括 5 次插入3 次删除
  1. 4 2
      src/display.ts
  2. 1 1
      src/kana.ts

+ 4 - 2
src/display.ts

@@ -284,10 +284,12 @@ namespace display {
     handleInput(key: string): void {
     handleInput(key: string): void {
       switch (this.state) {
       switch (this.state) {
         case LevelState.READY:
         case LevelState.READY:
-          this.onStart();
+          if (key == ' ' || key == 'Enter') {
+            this.onStart();
+          }
           break;
           break;
         case LevelState.PLAYING:
         case LevelState.PLAYING:
-          if (this.inputState !== null) {
+          if (this.inputState !== null && /^[-_ a-z]$/.test(key)) {
             if (this.inputState.handleInput(key)) {
             if (this.inputState.handleInput(key)) {
               this.onComplete();
               this.onComplete();
             }
             }

+ 1 - 1
src/kana.ts

@@ -277,7 +277,7 @@ namespace kana {
               kana.push(nextOne);
               kana.push(nextOne);
               if (/\s/.test(nextOne)) {
               if (/\s/.test(nextOne)) {
                 machines.push(WHITESPACE.clone());
                 machines.push(WHITESPACE.clone());
-              } else {
+              } else if (/[a-z]/.test(nextOne)) {
                 machines.push(literal(nextOne));
                 machines.push(literal(nextOne));
               }
               }
             }
             }