diff --git a/src/nano.c b/src/nano.c
index 6a0aeb31e0ce3589da53701ebec3a9471fe312d8..dca1c63d01c5dadc20e520177d6fc067369d8a16 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1267,9 +1267,15 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
     if (allow_funcs) {
 	/* If we got a mouse click and it was on a shortcut, read in the
 	 * shortcut character. */
-	if (*func_key == TRUE && input == KEY_MOUSE)
-	    input = do_mouse() ? get_kbinput(edit, meta_key, func_key) :
-		ERR;
+	if (*func_key == TRUE && input == KEY_MOUSE) {
+	    if (do_mouse())
+		input = get_kbinput(edit, meta_key, func_key);
+	    else {
+		*meta_key = FALSE;
+		*func_key = FALSE;
+		input = ERR;
+	    }
+	}
     }
 #endif
 
diff --git a/src/prompt.c b/src/prompt.c
index e9540c7cc04733a61712c64102ae2fa6ba461a34..f75f2b88bd74d82e20a6f55bc6e9e32834cfadaa 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -71,9 +71,15 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
     if (allow_funcs) {
 	/* If we got a mouse click and it was on a shortcut, read in the
 	 * shortcut character. */
-	if (*func_key == TRUE && input == KEY_MOUSE)
-	    input = do_statusbar_mouse() ? get_kbinput(bottomwin,
-		meta_key, func_key) : ERR;
+	if (*func_key == TRUE && input == KEY_MOUSE) {
+	    if (do_statusbar_mouse())
+		input = get_kbinput(bottomwin, meta_key, func_key);
+	    else {
+		*meta_key = FALSE;
+		*func_key = FALSE;
+		input = ERR;
+	    }
+	}
     }
 #endif