Remove globals from key handler