check if delegate is not null when dispatching keyboard event