Avoid crashes for invalid value of key modifiers