How to trigger an action on double-tap of a keyboard button?

The action of double-tapping would ideally be program-independent and should thus be implemented at a lower level than user programs or even window managers (which you don't want grabbing all keypresses to check for double-tapping).

The correct place to implement a feature like this would be in the X keyboard extensions. It could detect double tapping and let the user configure the keyname associated with it. Unfortunately, XKB does not yet support the action of double-tapping. You can do other cool things though, like remapping keys with xmodmap or even writing novel keyboard layouts (have look at the files in /usr/share/X11/xkb/symbols)