from stackoverflow.com/a/24065660java
//覆蓋Keyboard的getNearestKeys方法便可
@Override
public int[] getNearestKeys(int x, int y) {
List<Key> keys = getKeys();
for (int i = 0; i < keys.size(); i++) {
if (keys.get(i).isInside(x, y)) return new int[]{i};
}
return new int[0];
}
複製代碼