Skip to content

feat: include repeat property in trimmed keyboard events for plugins#1302

Merged
kwaroran merged 1 commit intokwaroran:mainfrom
OnlookerRs:feat/add-repeat-to-keyboard-event-trim
Mar 6, 2026
Merged

feat: include repeat property in trimmed keyboard events for plugins#1302
kwaroran merged 1 commit intokwaroran:mainfrom
OnlookerRs:feat/add-repeat-to-keyboard-event-trim

Conversation

@OnlookerRs
Copy link
Contributor

@OnlookerRs OnlookerRs commented Mar 2, 2026

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?
  • If your PR uses models1, check the following:
    • Have you checked if it works normally in all models?
    • Have you checked if it works normally in all web, local, and node-hosted versions? If it doesn't, have you blocked it in
  • If your PR is highly AI generated2, check the following:
    • Have you understood what the code does?
    • Have you cleaned up any unnecessary or redundant code?
    • Is it not a huge change?

Summary

The trimEvent function in SafeElement.addEventListener strips the repeat property from KeyboardEvent objects before forwarding them to V3 plugins. Without repeat, plugins cannot distinguish an initial key press from auto-repeated keydown events caused by holding a key, forcing plugin authors to implement manual debounce workarounds.

Related Issues

None

Changes

  • Added repeat: event.repeat to the trimmed KeyboardEvent object in SafeElement.addEventListener (v3.svelte.ts)

Impact

  • Plugins can now use if (e.repeat) return; to filter out held-key repeats, eliminating the need for manual debounce logic
  • No fingerprinting risk — repeat is a simple boolean that does not expose keystroke timing information
  • No breaking changes — existing plugins that don't use repeat are unaffected

Additional Notes

The existing trimmed properties (type, key, code, altKey, ctrlKey, shiftKey, metaKey) were chosen to avoid fingerprinting. repeat is consistent with this approach as it carries no timing data.

Footnotes

  1. Modifies the behavior of prompting, requesting, or handling responses from AI models.

  2. Over 80% of the code is AI generated.

@kwaroran kwaroran merged commit e8bef12 into kwaroran:main Mar 6, 2026
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.

2 participants