/** * Don't really need the full `event` for this, and picking these parts makes it * so that both the React keydown listener and native keydown listener can use * this function if needed. */ type KeyboardSubmitEventPartial = Pick< KeyboardEvent, "key" | "preventDefault" | "stopPropagation" | "currentTarget" >; /** * The default behavior when pressing the `"Enter"` key on a form control * (`input`, `textarea`, `select`) is to submit the form that the form control * is in. This util will try to polyfill this behavior for custom widgets that * use are using a role to act as a form control. * * The way this works is: * - Check if the `event.key` is the `"Enter"` key. Do nothing if it is not. * - Call `event.preventDefault()` and `event.stopPropagation()` to prevent * other unwanted keyboard behavior * - Check the event target to see if it is contained in a `