diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index 1a4f901950a135bc584f2397cd1a3111e91197bb..3b923e1fce658bb7c8078ee17cd8b3b25295052c 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -135,6 +135,6 @@ public abstract class KeyDetector {
                 mostCommonWidth = width;
             }
         }
-        return mostCommonWidth;
+        return mostCommonWidth + keyboard.getHorizontalGap();
     }
 }