Added mouse and keyboard input detection