Improve key event handling. Add Ime::KeyEvent and Ime::KeyState classes.