Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sometimes, when I use synergy between my machines when one is using full-screen VirtualBox guest I get stuck with some weird key modifiers turned on. If they exist on my keyboard (like Shift_L) I can just tap it and their status is reset and I can continue typing in small letters. But some of them are not mapped to my keyboard at all (like ISO_Level3_Shift), so I have no means of turning them off at all!

How to reset them? Right now, all I can do is to reboot the computer, but it's rather embarrassing solution.

All I want is some program that can artificially "tap" all possible keyboard modifiers, so their status would be reset. Can it be done?

I use Mint 14 (a clone of Ubuntu 12.10 Quantal).

share|improve this question

2 Answers 2

up vote 12 down vote accepted

If you have xdotool installed, you could just simply use

xdotool keyup ISO_Level3_Shift

Which sends a key release (for ISO_Level3_Shift, of course) event to the X server.

But you wanted a program to release all modifier keys. One could use xdotool to achieve that easily, if not for that I have no idea what modifier keysyms are defined. One possible method of finding them is to parse keysymdef.h:

grep '^#define' /usr/include/X11/keysymdef.h | sed -r 's/^#define XK_(\S*?).*$/\1/;' | grep -E '_(L|R|Level.*)$'

Which returns some keysyms that surely are modifiers. Unfortunately, I can't find any precise definition of a modifier key right now, so I don't know whether that's a complete list.

Appending | xargs xdotool keyup to the above pipeline will release all those keys. On my system, it executes the following command:

xdotool keyup Shift_L Shift_R Control_L Control_R Meta_L Meta_R Alt_L Alt_R Super_L Super_R Hyper_L Hyper_R ISO_Level2_Latch ISO_Level3_Shift ISO_Level3_Latch ISO_Level3_Lock ISO_Level5_Shift ISO_Level5_Latch ISO_Level5_Lock
share|improve this answer
Great answer, and works like a charm! – Adam Ryczkowski Jan 1 '14 at 13:26
Great! I also found that unassigned keys could be unstuck via the keycode, e.g. xdotool keyup 204. – Adam Spiers May 7 at 0:13
@Adam Spiers clued me in. The keyup code for my case was an xmodmap code, e.g. 204, and using keysymdef.h didn't help. To see the xmodmap key codes, try: DISAPLAY=:1 xmodmap -pk | grep -iP 'alt|meta|super|hyper'. You'll need to change the display number to your broken VNC display number. – srking Nov 18 at 22:17
I think you meant DISPLAY=:1 in the above comment. – Adam Spiers Nov 19 at 9:47

I use "setxkbmap" with no arguments. It seems to reset the keyboard. I have a "shortcut" in my panel that I can use with a mouse for when the keyboard is completely inoperable.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.