Added handling of key events