Safari on older iOS doesn't support creating KeyboardEvent objects, so put a guard in to avoid crashes.