Fixed a bug in the console event handler