Letting modifier keys act as toggles under X

Is there any way to let the Shift, Ctrl and Alt keys behave as toggles under X? I know how one could do it under CLI (for example, by doing this) but found no reference for doing so under X.

Please note that this is not a question on sticky keys, which can be enabled by an accessibility option.


This is implemented on the DE level AFAIK. KDE has the option to Lock Sticky Keys:

With Lock Sticky Keys enabled:

If you press the Shift key twice then press the F key, the computer interprets this as Shift+F. Now if you type a P, the computer interprets this as the letter P (Shift+P). To de-select the Shift key, press it again.

http://docs.kde.org/stable/en/kdebase-workspace/kcontrol/kcmaccess/index.html