Is there a built-in variable which gives the last inserted character of a buffer (inserted by self-insert-command)? Note that the cursor is not necessarily at the place of the last insertion.
If there is not such a variable, any other solution for defining a variable which determines this character would be helpful.
post-command-hook
that tracks the argument ifthis-command
isself-insert
and checks forthis-command-keys
to figure out what key was hit to insert the character.