Revised key event support to remove some invalid casts, fix bugs relating