I use the following command in a bash script file:

xdotool type --clearmodifiers $(xclip -o -sel c)

I invoke it with a shortcut such as CTRL+SHIFT+e

The action works as expected. However, after it completes, the modifier keys remain pressed. That's the problem I need to resolve.

From the xdotool man page, the issue makes some sense:

Any command taking the --clearmodifiers flag will attempt to clear any active input modifiers during the command and restore them afterwards.

I wish they were not restored, but since they are, I need an additional command to clear those modifiers.


I tried adding these lines at the end of my script file:

xdotool keyup Control
xdotool keyup Shift

That resulted in me not being able to type or even use the mouse correctly.

I'm using KDE and X11. I use the US International keyboard layout and I have the following keyboard customizations set in KDE system settings:

  1. both shift keys together enable caps lock and one shift key disables it
  2. Caps Lock as Ctrl
  • 1
    You could try using keyup Control keyup Shift at the start of the xdotool command instead of --clearmodifiers which would then not be needed.
    – meuh
    Commented Nov 4, 2019 at 15:05
  • Good idea. I will try that.
    – MountainX
    Commented Nov 14, 2019 at 4:46

1 Answer 1


Keydown messages for CTRL+SHIFT+e (the activator keystrokes) have already been sent and the keyup for the modifier keys do not get sent.

sleep 0.2
xdotool keyup Control_L Control_R Shift_L Shift_R

The actual key (e) may also have to be listed in keyup, but I do not have a problem excluding it. The sleep command is not always needed, but placing it before every xdotool command helps speed issues because xdotool is fast.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .