AutoKey is a great piece of software. Still works although last updates are few years back. Since it allows python script embedding it is incredibly extensible.
Due to google code migration the documentation is no longer easily available but here is a link to the last snapshot:
Mailing group (still active):
https://groups.google.com/forum/#!forum/autokey-users
Favourite script threads for inspiration:
https://groups.google.com/forum/#!topic/AutoKey-users/7QCJyEyzqkA
https://groups.google.com/forum/#!topic/AutoKey-users/O240aoJFYPY
Good overview of features: