Skip to content

Conversation

@reidbarber
Copy link
Member

@reidbarber reidbarber commented Jan 15, 2026

Related discussion: #9487

Passes through the key property to PressEvent, which makes it easier to tell if the keyboard-triggered press event was from a Space or Enter key press.

Allows us to remove these hacks:

function isActionKey() {
let event = window.event as KeyboardEvent;
return event?.key === 'Enter';
}
function isSelectionKey() {
let event = window.event as KeyboardEvent;
return event?.key === ' ' || event?.code === 'Space';
}

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Open a Button story in storybook and check the PressEvent object in the Actions panel.

🧢 Your Project:

@rspbot
Copy link

rspbot commented Jan 15, 2026

@rspbot
Copy link

rspbot commented Jan 15, 2026

## API Changes

react-aria-components

/react-aria-components:PressEvent

 PressEvent {
   altKey: boolean
   continuePropagation: () => void
   ctrlKey: boolean
+  key?: string
   metaKey: boolean
   pointerType: PointerType
   shiftKey: boolean
   target: Element
   x: number
   y: number
 }

@react-aria/interactions

/@react-aria/interactions:PressEvent

 PressEvent {
   altKey: boolean
   continuePropagation: () => void
   ctrlKey: boolean
+  key?: string
   metaKey: boolean
   pointerType: PointerType
   shiftKey: boolean
   target: Element
   x: number
   y: number
 }

@reidbarber reidbarber enabled auto-merge January 15, 2026 23:39
@yihuiliao yihuiliao added the RAC label Jan 16, 2026
@reidbarber reidbarber added this pull request to the merge queue Jan 16, 2026
Merged via the queue into main with commit 732355b Jan 16, 2026
33 checks passed
@reidbarber reidbarber deleted the add-key-usePress branch January 16, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants