Spacebar like hotkey

I was wondering if it would be possible to write a script wich assigned to a key will do the same as the spacebar hotkey (one thing if I 'tap' it and another one if I keep it pressed).
I want to do this because in linux (or at least in some setups), there is a problem with the spacebar panePop function and I can't find a solution. If I'm moving the mouse the panePop function won't work when I 'tap' the spacebar. But I discovered that if I assign the panePop function to another hotkey it works fine when I'm moving the mouse. So I wanted to write a script that would do the same, but maybe not the default way and assign it to the spacebar.
Thank you.

i make a lot of my scripts work in that "dual mode". when you tap the key, it does a "default" action, and when you hold it, it brings up a menu. its not exactly like spacebar, but its similar.

have a look at this script to see how its done, but basically it works like this:

when the script is run, it builds a global variable, and sets it to zero. when the mouse button is clicked, a popupmenu is built, and the variable is set to 1. then on the button release command, it runs a proc whcih checks the global variable. if its on, it destroys the popupmenu, and assumes the user chose a command to run from the menu.

otherwise, it runs a default action (usually i try to make this default action user choosable).

so its not exactly the same, but it really makes using popupmenus faster and more powerful. by default, maya has the w, e and r hotkeys set up this same way too...

Well, thank you for your help, I've been trying to do some things, some alternatives using your method, but couldn't find a way to solve it. I can't find a function that will show the hotbox but don't do the panepop, the two functions are in the command "hotBox" and theres where the problem relies, I can't get the function to show the hotbox alone. Anyway, if someone can think a way to mimic the spacebar default action I will apreciate.
Anyway, I couldn't solve the problem but all the things I tried were a good introdiction to some MEL programming.