diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index e730b173dd..7fbfc5db32 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -1156,21 +1156,21 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
   gboolean compose_match;
   gunichar output_char;
 
   while (priv->compose_buffer[n_compose] != 0)
     n_compose++;
 
   if (event->type == GDK_KEY_RELEASE)
     {
-      if ((event->keyval == GDK_KEY_Control_L || event->keyval == GDK_KEY_Control_R ||
+      if ((priv->in_hex_sequence || priv->in_emoji_sequence) &&
+          (event->keyval == GDK_KEY_Control_L || event->keyval == GDK_KEY_Control_R ||
           event->keyval == GDK_KEY_Shift_L || event->keyval == GDK_KEY_Shift_R))
        {
-          if ((priv->in_hex_sequence || priv->in_emoji_sequence) &&
-             priv->tentative_match &&
+          if (priv->tentative_match &&
              g_unichar_validate (priv->tentative_match))
            {
              gtk_im_context_simple_commit_char (context, priv->tentative_match);
              priv->compose_buffer[0] = 0;
 
            }
          else if (priv->in_emoji_sequence ||
                    (priv->in_hex_sequence && n_compose == 0))
