Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(checkbox): Add keyboard handling for Enter and Space keys to tog… #946

Merged
merged 6 commits into from
Nov 13, 2024

Conversation

mryunt02
Copy link
Contributor

Summary of Changes

  • Added keyboard functionality to the input component to toggle the checked state when the Enter or Space key is pressed.

Changes Made

  1. Implemented the handleKeyDown function:
private handleKeyDown(event: KeyboardEvent) {
    if (event.code === "Enter" || event.code === "Space") {
        this.checked = !this.checked;
        this.onChange(this.checked);
        event.preventDefault();
    }
}

  1. Associated the function with the @keydown event listener:
    <input @keydown=${this.handleKeyDown} />

Reason for Changes

This change was made to enhance user interaction with form elements via the keyboard and to improve accessibility.

@erbilnas erbilnas merged commit dd096eb into Trendyol:next Nov 13, 2024
5 checks passed
Copy link

🎉 This PR is included in version 3.3.0-beta.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

4 participants