Added key events and some fixes