diff --git a/gdk/quartz/gdkkeys-quartz.c b/gdk/quartz/gdkkeys-quartz.c
index 5b4a79a..19a20f5 100644
--- a/gdk/quartz/gdkkeys-quartz.c
+++ b/gdk/quartz/gdkkeys-quartz.c
@@ -688,12 +688,18 @@ gdk_keymap_translate_keyboard_state (GdkKeymap       *keymap,
 
   if (hardware_keycode < 0 || hardware_keycode >= NUM_KEYCODES)
     return FALSE;
-  
-  /* Check if shift or capslock modify the keyval */
-  for (bit = GDK_SHIFT_MASK; bit < GDK_CONTROL_MASK; bit <<= 1)
+
+  /* Check if modifiers modify the keyval */
+  for (bit = GDK_SHIFT_MASK; bit < GDK_BUTTON1_MASK; bit <<= 1)
     {
-      if (translate_keysym (hardware_keycode, group, state & ~bit, NULL, NULL) !=
-	  translate_keysym (hardware_keycode, group, state | bit, NULL, NULL))
+      if (translate_keysym (hardware_keycode,
+                            (bit == GDK_MOD1_MASK) ? 0 : group,
+                            state & ~bit,
+                            NULL, NULL) !=
+	  translate_keysym (hardware_keycode,
+                            (bit == GDK_MOD1_MASK) ? 1 : group,
+                            state | bit,
+                            NULL, NULL))
 	tmp_modifiers |= bit;
     }
 
diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c
index 846b1ec..694d40a 100644
--- a/gtk/gtkcellrendereraccel.c
+++ b/gtk/gtkcellrendereraccel.c
@@ -406,11 +406,14 @@ grab_key_callback (GtkWidget            *widget,
                    GtkCellRendererAccel *accel)
 {
   GdkModifierType accel_mods = 0;
+  gint group;
   guint accel_key;
+  guint keyval;
   gchar *path;
   gboolean edited;
   gboolean cleared;
   GdkModifierType consumed_modifiers;
+  gboolean group_mask_disabled = FALSE;
   GdkDisplay *display;
 
   display = gtk_widget_get_display (widget);
@@ -421,16 +424,40 @@ grab_key_callback (GtkWidget            *widget,
   edited = FALSE;
   cleared = FALSE;
 
+  accel_mods = event->state;
+  group = event->group;
+
+  /* if the group-toggling modifier is part of the default accel mod
+   * mask, and it is active, disable it for matching
+   */
+  if (accel_mods & gtk_accelerator_get_default_mod_mask () & GTK_TOGGLE_GROUP_MOD_MASK)
+    {
+      g_printerr ("removing MOD1\n");
+      accel_mods &= ~GTK_TOGGLE_GROUP_MOD_MASK;
+      group = 0;
+      group_mask_disabled = TRUE;
+    }
+
   gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (display),
 				       event->hardware_keycode,
-                                       event->state,
-                                       event->group,
-				       NULL, NULL, NULL, &consumed_modifiers);
+                                       accel_mods,
+                                       group,
+				       &keyval, NULL, NULL, &consumed_modifiers);
+
+  g_printerr ("consumed: %d\n", consumed_modifiers);
+
+  /* add back the group mask, we want to display the modifier, but not
+   * the keyval from its group
+   */
+  if (group_mask_disabled)
+    {
+      accel_mods |= GTK_TOGGLE_GROUP_MOD_MASK;
+      consumed_modifiers &= ~GTK_TOGGLE_GROUP_MOD_MASK;
+    }
 
-  accel_mods = event->state;
   gdk_keymap_add_virtual_modifiers (gdk_keymap_get_for_display (display), &accel_mods);
 
-  accel_key = gdk_keyval_to_lower (event->keyval);
+  accel_key = gdk_keyval_to_lower (keyval);
   if (accel_key == GDK_ISO_Left_Tab) 
     accel_key = GDK_Tab;
 
@@ -443,12 +470,12 @@ grab_key_callback (GtkWidget            *widget,
   
   /* Put shift back if it changed the case of the key, not otherwise.
    */
-  if (accel_key != event->keyval)
+  if (accel_key != keyval)
     accel_mods |= GDK_SHIFT_MASK;
     
   if (accel_mods == 0)
     {
-      switch (event->keyval)
+      switch (keyval)
 	{
 	case GDK_Escape:
 	  goto out; /* cancel */
diff --git a/gtk/gtkkeyhash.c b/gtk/gtkkeyhash.c
index cbe0b77..532b90c 100644
--- a/gtk/gtkkeyhash.c
+++ b/gtk/gtkkeyhash.c
@@ -18,9 +18,12 @@
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
+
 #include "config.h"
+
 #include "gtkdebug.h"
 #include "gtkkeyhash.h"
+#include "gtkprivate.h"
 #include "gtkalias.h"
 
 typedef struct _GtkKeyHashEntry GtkKeyHashEntry;
@@ -392,6 +395,7 @@ _gtk_key_hash_lookup (GtkKeyHash      *key_hash,
   gint level;
   GdkModifierType modifiers;
   GdkModifierType consumed_modifiers;
+  gboolean group_mask_disabled = FALSE;
   const GdkModifierType xmods = GDK_MOD2_MASK|GDK_MOD3_MASK|GDK_MOD4_MASK|GDK_MOD5_MASK;
   const GdkModifierType vmods = GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK;
 
@@ -399,11 +403,31 @@ _gtk_key_hash_lookup (GtkKeyHash      *key_hash,
    */
   state &= ~GDK_LOCK_MASK;
 
+  /* if the group-toggling modifier is part of the default accel mod
+   * mask, and it is active, disable it for matching
+   */
+  if (mask &state & GTK_TOGGLE_GROUP_MOD_MASK)
+    {
+      state &= ~GTK_TOGGLE_GROUP_MOD_MASK;
+      group = 0;
+      group_mask_disabled = TRUE;
+    }
+
   gdk_keymap_map_virtual_modifiers (key_hash->keymap, &mask);
 
   gdk_keymap_translate_keyboard_state (key_hash->keymap,
 				       hardware_keycode, state, group,
 				       &keyval, &effective_group, &level, &consumed_modifiers);
+
+  /* add back the group mask, we want to match against the modifier,
+   * but not against the keyval from its group
+   */
+  if (group_mask_disabled)
+    {
+      state |= GTK_TOGGLE_GROUP_MOD_MASK;
+      consumed_modifiers &= ~GTK_TOGGLE_GROUP_MOD_MASK;
+    }
+
   gdk_keymap_add_virtual_modifiers (key_hash->keymap, &state);
 
   GTK_NOTE (KEYBINDINGS,
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index 53afe0e..942842c 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -133,6 +133,12 @@ gboolean _gtk_fnmatch (const char *pattern,
 #define GTK_MODIFY_SELECTION_MOD_MASK GDK_MOD2_MASK
 #endif
 
+#ifndef GDK_WINDOWING_QUARTZ
+#define GTK_TOGGLE_GROUP_MOD_MASK 0
+#else
+#define GTK_TOGGLE_GROUP_MOD_MASK GDK_MOD1_MASK
+#endif
+
 gboolean _gtk_button_event_triggers_context_menu (GdkEventButton *event);
 
 G_END_DECLS
