Skip to content

Construct complete OpenTUI KeyEvent instances for synthetic command events #767

Description

@benvinegar

Problem

synthesizeKeyEvent returns a plain object asserted as OpenTUI's KeyEvent.

The synthetic object contains the chord fields used by current matching, but omits required event fields such as eventType and source. Its preventDefault and stopPropagation methods also do not update the state exposed by real KeyEvent getters.

The current round-trip test only verifies chord matching. Synthetic events are also passed to command matchers and programmatically invoked handlers, which may legitimately inspect the rest of the KeyEvent contract.

Proposed direction

Construct the exported OpenTUI KeyEvent class with a complete parsed-key payload instead of asserting a partial object.

Use explicit synthetic defaults such as eventType: "press" and source: "raw" unless a more appropriate source is available.

Acceptance criteria

  • synthesizeKeyEvent returns a real KeyEvent instance without a double assertion.
  • Existing chord matching behavior remains unchanged.
  • eventType and source are populated.
  • preventDefault and stopPropagation update the corresponding observable state.
  • Extend tests beyond chord round-tripping to cover the complete synthetic event behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions