private int indexOf(int keyCode) {
    for (int i = 0; i < keys.length; i++) {
      int key = keys[i];
      if (key == keyCode) return i;
      if (key > keyCode) return -i-1;
    }
    return -keys.length - 1;
  }
private int indexOf(int keyCode)