Skip to content

Adding helper function to detect input#425

Open
asengupta3 wants to merge 1 commit intomainfrom
get-input-capability
Open

Adding helper function to detect input#425
asengupta3 wants to merge 1 commit intomainfrom
get-input-capability

Conversation

@asengupta3
Copy link
Collaborator

Usage:

const detector = setupInputDetection();

console.log(detector.capability);
// { touch: boolean, mouse: boolean, primary: "touch" | "mouse" | "unknown" }

console.log(detector.getCurrentInput());
// "touch" | "mouse" | "keyboard" | "unknown" | null

This uses:

  1. Both media query to preemptively determine the input method
  2. But also adds listeners to update the values whenever interaction is detected
  3. So this function can be called very early in the task load and then called whenever to get the most updated touch value

Copy link
Collaborator

@digital-pro digital-pro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, or as I traditionally misread that acronym (LGTR -- Let the good times roll)

@CCuskley
Copy link

CCuskley commented Mar 3, 2026

Looks good to me in terms of code - but do we want to consider aligning with ROAR tasks here? They're using these custom utils that draw on the detect-it package...I'm not necessarily sure it's better, but we might want to consider if/when the methods have discrepancies

Copy link
Collaborator

@zwatson2001 zwatson2001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I can test this on a few different devices before we merge, and I'm also happy to add this to H&F once we make a final decision about how to handle the instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants