Skip to content

[question] cdk keycodes #7358

Closed
Closed

Description

@abdel-ships-it

Whats the idea behind using the keycodes in here ?

I was looking at your implementation of the dialog and have noticed you are using it to for example detect when the user pressed escape.

You do that in a rather interesting way, you add an event listener to the document which executes a method which eventually checks the keycode.

My question is, why did you prefer this approach for handling keydown events instead of using HostListener like this.

@HostListener('document:keydown.Escape', ['$event']) ...

I am fully aware of the fact I should be on Stackoverflow for questions, but this question is related to internal code rather than the usage of it, therefor I thought this would be a better place.

Activity

  1. willshowell commented on Sep 27, 2017

    @willshowell
    Contributor

    Related #3082 and #6682

  2. josephperrott commented on Sep 27, 2017

    @josephperrott
    Member

    Closing as the discussion and explanations are available in the prs linked above.

  3. abdel-ships-it commented on Sep 27, 2017

    @abdel-ships-it
    Author

    @willshowell Although PR #3082 demonstrates the usage of document.addListener('keydown').... I don't understand why that approach was preferred over HostListener. In the PR host is replaced with the verbose addListener approach, but HostListener would have got the job done in a cleaner fashion.

    Both approaches work just fine, the one is just way more code than the other. And I'm curious based on what the decision was made :)

  4. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions