diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index af854ce..adc6ee7 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1859,34 +1859,32 @@ gtk_main_do_event (GdkEvent *event)
       /* make focus visible in a window that receives a key event */
       {
         GtkWidget *window;
+	guint mnemonic_modifier;
 
         window = gtk_widget_get_toplevel (grab_widget);
-        if (GTK_IS_WINDOW (window))
+        if (GTK_IS_WINDOW (window)) {
           gtk_window_set_focus_visible (GTK_WINDOW (window), TRUE);
+
+	  /* Catch mnemonic modifier press to enable auto-mnemonics;
+	   * menus are handled elsewhere.
+	   */
+	  mnemonic_modifier = gtk_window_get_mnemonic_modifier (GTK_WINDOW(window));
+
+	  if (_gtk_window_has_mnemonic_modifier_pressed (GTK_WINDOW (window)) &&
+	      ((event->key.state & (gtk_accelerator_get_default_mod_mask ()) & ~(GDK_RELEASE_MASK|mnemonic_modifier)) == 0) &&
+	      !GTK_IS_MENU_SHELL (grab_widget))
+	    {
+	      gboolean mnemonics_visible;
+
+	      mnemonics_visible = (event->type == GDK_KEY_PRESS);
+
+	      if (mnemonics_visible)
+	        _gtk_window_schedule_mnemonics_visible (GTK_WINDOW (window));
+	      else
+	        gtk_window_set_mnemonics_visible (GTK_WINDOW (window), FALSE);
+	    }
+	}
       }
-
-      /* Catch alt press to enable auto-mnemonics;
-       * menus are handled elsewhere
-       * FIXME: this does not work with mnemonic modifiers other than Alt
-       */
-      if ((event->key.keyval == GDK_KEY_Alt_L || event->key.keyval == GDK_KEY_Alt_R) &&
-          ((event->key.state & (gtk_accelerator_get_default_mod_mask ()) & ~(GDK_RELEASE_MASK|GDK_MOD1_MASK)) == 0) &&
-          !GTK_IS_MENU_SHELL (grab_widget))
-        {
-          gboolean mnemonics_visible;
-          GtkWidget *window;
-
-          mnemonics_visible = (event->type == GDK_KEY_PRESS);
-
-          window = gtk_widget_get_toplevel (grab_widget);
-          if (GTK_IS_WINDOW (window))
-            {
-              if (mnemonics_visible)
-                _gtk_window_schedule_mnemonics_visible (GTK_WINDOW (window));
-              else
-                gtk_window_set_mnemonics_visible (GTK_WINDOW (window), FALSE);
-            }
-        }
       /* else fall through */
     case GDK_SCROLL:
     case GDK_BUTTON_PRESS:
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index a4ba098..e99caeb 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -8382,8 +8382,8 @@ do_focus_change (GtkWidget *widget,
   g_object_unref (widget);
 }
 
-static gboolean
-gtk_window_has_mnemonic_modifier_pressed (GtkWindow *window)
+gboolean
+_gtk_window_has_mnemonic_modifier_pressed (GtkWindow *window)
 {
   GList *seats, *s;
   gboolean retval = FALSE;
diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h
index 5cb5a72..07938b5 100644
--- a/gtk/gtkwindowprivate.h
+++ b/gtk/gtkwindowprivate.h
@@ -77,6 +77,8 @@ void _gtk_window_keys_foreach (GtkWindow               *window,
 
 gboolean _gtk_window_check_handle_wm_event (GdkEvent  *event);
 
+gboolean _gtk_window_has_mnemonic_modifier_pressed (GtkWindow *window);
+
 /* --- internal (GtkAcceleratable) --- */
 gboolean        _gtk_window_query_nonaccels     (GtkWindow      *window,
                                                  guint           accel_key,
