How to reset stuck key after failed xdotool command?

In my window manager I use keybindings with Alt which call xdotool command with --clearmodifiers flag. I set --delay 4 flag, which is low enough, but the problem is that sometimes I release Alt key too rarely, before the chain of commands finishes. In this case, --clearmodifiers flag calls keydown on Alt, and Alt gets stuck, and I cannot perform any command in display mode. It happens rarely but I wonder what’d be the pill for it when it does?

I can log into the terminal mode by Crtl+Alt+F2, but I have no idea on what to do next. Tried to reload my keyboard by
rmmod atkbd ; modprobe atkbd reset=1
And it changes nothing.
Tried to reload my wm, and the terminal says:
Can't access display mode
(or something like that)
Same with trying to invoke xdotool in terminal mode.

The solution seems to be creating a specific keybinding that sends xdotool keydown command on Alt in display mode, but this seems ugly.
I’d like to know, is there any way to reset such failed xdotool command result from the terminal mode without rebooting?

Perhaps try to kill it:

pkill xdotool


pkill -hup xdotool

But I don’t use xdotool so I’m just guessing here.

FWIW the ArchWiki describes it as “very buggy” and says that development has ceased[0] so perhaps you should try something else instead.

Why do you need the clearmodifiers flag? If it fails could you just send a keyup through xdotool

xdotool ... || xdotool keyup alt

Just ideas though, not actual commands

Because when the chain of commands starts to execute, alt is still pressed because, well, I am not as fast as a computer. And putting sleep for half of a second is a waste of time when typing.
And xdotool commands don’t work from the terminal mode, says Can't access display mode.

That doesn’t work as well.
Probably, you are right and using another utility can solve the issue.
However, I’ve found the different way around with another key bindings.
(I’m not sure if I should close the topic because that’s not actually the solution.)