Take the 2-minute tour ×
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
add comment

2 Answers

up vote 8 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 at 13:26
add comment

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
add comment

Your Answer

 
discard

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.