diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index e163457d8c2d8a90dd0b6146f1fc8356b68d9622..5bf8aa8b3590a3ff868e3ee2703c5b4d238fb0f2 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -486,6 +486,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
             } else if (isShiftLocked() && !shiftKeyState.isIgnoring() && !withSliding) {
                 // Shift has been pressed without chording while caps lock state.
                 toggleCapsLock();
+                // To be able to turn off caps lock by "double tap" on shift key, we should ignore
+                // the second tap of the "double tap" from now for a while because we just have
+                // already turned off caps lock above.
+                mInputView.startIgnoringDoubleTap();
             } else if (isShiftedOrShiftLocked() && shiftKeyState.isPressingOnShifted()
                     && !withSliding) {
                 // Shift has been pressed without chording while shifted state.
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index c36895258495e49f6603b13e7861d895033ba0cc..b6f2cab01ac562b66beffb6b180fd118db9629eb 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -44,6 +44,7 @@ import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewConfiguration;
 import android.view.ViewGroup;
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
@@ -189,6 +190,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
         private static final int MSG_REPEAT_KEY = 3;
         private static final int MSG_LONGPRESS_KEY = 4;
         private static final int MSG_LONGPRESS_SHIFT_KEY = 5;
+        private static final int MSG_IGNORE_DOUBLE_TAP = 6;
 
         private boolean mInKeyRepeat;
 
@@ -286,6 +288,16 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
         public void cancelKeyTimers() {
             cancelKeyRepeatTimer();
             cancelLongPressTimers();
+            removeMessages(MSG_IGNORE_DOUBLE_TAP);
+        }
+
+        public void startIgnoringDoubleTap() {
+            sendMessageDelayed(obtainMessage(MSG_IGNORE_DOUBLE_TAP),
+                    ViewConfiguration.getDoubleTapTimeout());
+        }
+
+        public boolean isIgnoringDoubleTap() {
+            return hasMessages(MSG_IGNORE_DOUBLE_TAP);
         }
 
         public void cancelAllMessages() {
@@ -449,7 +461,12 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
                     final PointerTracker tracker = getPointerTracker(id);
                     // If the second down event is also on shift key.
                     if (tracker.isOnShiftKey((int)secondDown.getX(), (int)secondDown.getY())) {
-                        onDoubleTapShiftKey(tracker);
+                        // Detected a double tap on shift key. If we are in the ignoring double tap
+                        // mode, it means we have already turned off caps lock in
+                        // {@link KeyboardSwitcher#onReleaseShift} .
+                        final boolean ignoringDoubleTap = mHandler.isIgnoringDoubleTap();
+                        if (!ignoringDoubleTap)
+                            onDoubleTapShiftKey(tracker);
                         return true;
                     }
                     // Otherwise these events should not be handled as double tap.
@@ -468,6 +485,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
         mKeyRepeatInterval = res.getInteger(R.integer.config_key_repeat_interval);
     }
 
+    public void startIgnoringDoubleTap() {
+        if (ENABLE_CAPSLOCK_BY_DOUBLETAP)
+            mHandler.startIgnoringDoubleTap();
+    }
+
     public void setOnKeyboardActionListener(KeyboardActionListener listener) {
         mKeyboardActionListener = listener;
         for (PointerTracker tracker : mPointerTrackers) {