Hold on first press, release on second?

Hold on first press, release on second?

Is there a way to make it so that I can press a button, for example, Mouse 4, and on first press it then presses and holds a keyboard character key, again for example "x".

I want to then be able to press that same mouse 4 button to release the held "x" keyboard key.

Is this currently possible?