For X11, there's xcape: https://github.com/alols/xcape
For Windows, of course, AutoHotKey (my config: https://github.com/myfreeweb/dotfiles/blob/master/windows/ke...)