If we unregister the last key event listener we will uninstall the key event
snooper, so we need to reinstall it when a new key event listener is added.
The listener id is postincremented as a subexpression of being inserted into
the hash table. That means the key inserted into the table is 1 less than the
value returned from the function. Which means that later attempts to remove
the returned id will fail because that hash table knows about a different id.