diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 82be9cc9209..69bcf8e56b7 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -400,7 +400,9 @@ void process_action(keyrecord_t *record, action_t action) {
         /* Mouse key */
         case ACT_MOUSEKEY:
             if (event.pressed) {
+                mousekey_on(action.key.code);
                 switch (action.key.code) {
+#    ifdef PS2_MOUSE_ENABLE
                     case KC_MS_BTN1:
                         tp_buttons |= (1 << 0);
                         break;
@@ -410,13 +412,15 @@ void process_action(keyrecord_t *record, action_t action) {
                     case KC_MS_BTN3:
                         tp_buttons |= (1 << 2);
                         break;
+#    endif
                     default:
+                        mousekey_send();
                         break;
                 }
-                mousekey_on(action.key.code);
-                mousekey_send();
             } else {
+                mousekey_off(action.key.code);
                 switch (action.key.code) {
+#    ifdef PS2_MOUSE_ENABLE
                     case KC_MS_BTN1:
                         tp_buttons &= ~(1 << 0);
                         break;
@@ -426,11 +430,11 @@ void process_action(keyrecord_t *record, action_t action) {
                     case KC_MS_BTN3:
                         tp_buttons &= ~(1 << 2);
                         break;
+#    endif
                     default:
+                        mousekey_send();
                         break;
                 }
-                mousekey_off(action.key.code);
-                mousekey_send();
             }
             break;
 #endif