Index: plugins/common/gsd-keygrab.c
===================================================================
--- plugins/common/gsd-keygrab.c	(revision 321)
+++ plugins/common/gsd-keygrab.c	(working copy)
@@ -24,6 +24,11 @@
 
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
+#ifdef HAVE_X11_EXTENSIONS_XKB_H
+#include <X11/XKBlib.h>
+#include <X11/extensions/XKB.h>
+#include <gdk/gdkkeysyms.h>
+#endif
 
 #include "gsd-keygrab.h"
 
@@ -119,9 +124,56 @@
         }
 }
 
+static gboolean
+have_xkb (Display *dpy)
+{
+	static int have_xkb = -1;
+
+	if (have_xkb == -1) {
+		int opcode, error_base, major, minor, xkb_event_base;
+
+		gdk_error_trap_push ();
+		have_xkb = XkbQueryExtension (dpy,
+					      &opcode,
+					      &xkb_event_base,
+					      &error_base,
+					      &major,
+					      &minor)
+			&& XkbUseExtension (dpy, &major, &minor);
+		gdk_error_trap_pop ();
+	}
+
+	return have_xkb;
+}
+
 gboolean
 match_key (Key *key, XEvent *event)
 {
+	GdkKeymap *keymap;
+	guint keyval;
+	GdkModifierType consumed;
+	gint group;
+
+	if (key == NULL)
+		return FALSE;
+
+	keymap = gdk_keymap_get_default ();
+	if (have_xkb (event->xkey.display))
+		group = XkbGroupForCoreState (event->xkey.state);
+	else
+		group = (event->xkey.state & GDK_Mode_switch) ? 1 : 0;
+	/* Check if we find a keysym that matches our current state */
+	if (gdk_keymap_translate_keyboard_state (keymap, event->xkey.keycode,
+					     event->xkey.state, group,
+					     &keyval, NULL, NULL, &consumed)) {
+		if (keyval == key->keysym
+		    && (key->state & ~consumed & GSD_USED_MODS) == key->state) {
+		    	return TRUE;
+		}
+		return FALSE;
+	}
+
+	/* The key we passed doesn't have a keysym, so try with just the keycode */
         return (key != NULL
                 && key->keycode == event->xkey.keycode
                 && key->state == (event->xkey.state & GSD_USED_MODS));
