@Override
 public int getKeyIndexAndNearbyCodes(int x, int y, int[] allKeys) {
   final Key[] keys = getKeys();
   final int touchX = getTouchX(x);
   final int touchY = getTouchY(y);
   int closestKeyIndex = AnyKeyboardViewBase.NOT_A_KEY;
   int closestKeyDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
   final int keyCount = keys.length;
   for (int i = 0; i < keyCount; i++) {
     final Key key = keys[i];
     int dist = key.squaredDistanceFrom(touchX, touchY);
     if (dist < closestKeyDist) {
       closestKeyIndex = i;
       closestKeyDist = dist;
     }
   }
   if (allKeys != null && closestKeyIndex != AnyKeyboardViewBase.NOT_A_KEY) {
     final Key key = keys[closestKeyIndex];
     allKeys[0] = key.getCodeAtIndex(0, isKeyShifted(key));
   }
   return closestKeyIndex;
 }