Improve key event handling, adding support for Capslock and English mode.