Added alert dialog and fixed on key listener bug