private void onKey(char ch) {
    if (!buttonOk.isEnabled()) {
      return;
    }

    System.out.println("key='" + ch + "' (" + (int) ch + ")");
    System.out.println("enter=(" + (int) '\n' + ")");
    System.out.println("bs=(" + (int) '\b' + ")");

    // Enter == OKボタン
    if (ch == '\n' || ch == '\r') {
      // 1問につき複数回解答が送信できてしまうバグへの対処
      if (buttonOk.isEnabled()) {
        onOk();
      }
      return;
    }

    // Back Space == 消すボタン
    if (ch == '\b') {
      onErase();
      return;
    }

    String letter = "" + ch;
    letter = letter.toUpperCase();
    if (!ACCEPTED_KEYS.contains(letter)) {
      return;
    }
    letter = StringUtils.toFullWidth(letter);

    addLetterToAnswer(letter);
  }
 @VisibleForTesting
 void addLetterToAnswer(String letter) {
   String answer = answerView.getRaw();
   answer += letter;
   switch (letterType) {
     case Alphabet:
       break;
     case Hiragana:
       answer = StringUtils.convertLastAlphabetToKana(answer, LetterType.Hiragana);
       break;
     case Katakana:
       answer = StringUtils.convertLastAlphabetToKana(answer, LetterType.Katakana);
       break;
   }
   answerView.set(answer, true);
 }
 private void onOk() {
   enable(false);
   String answer = answerView.get();
   if (letterType != LetterType.Alphabet) {
     answer =
         StringUtils.convertLastAlphabetToKanaBeforeSendAnswer(
             answer,
             letterType == LetterType.Hiragana ? LetterType.Hiragana : LetterType.Katakana);
   }
   answerView.set(answer, true);
   sendAnswer(answer);
 }
 private void onErase() {
   String answer = answerView.get();
   answer = StringUtils.removeLast(answer);
   answerView.set(answer, true);
 }