added comments, tidied up, enabled custom event for just exit or enter