Well there are many ways. But I am guessing you are interested in an advanced implementation. Few days back I was in same search, and I found one.
It's good for capturing events from keyboard and you will find the character maps too. And good thing is ... it's jQuery. Check the demo on same page and decide.
An alternative library is here.