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

[question] cdk keycodes #7358

Closed
abdel-ships-it opened this issue Sep 27, 2017 · 4 comments
Closed

[question] cdk keycodes #7358

abdel-ships-it opened this issue Sep 27, 2017 · 4 comments

Comments

@abdel-ships-it
Copy link

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.

@willshowell
Copy link
Contributor

Related #3082 and #6682

@josephperrott
Copy link
Member

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

@abdel-ships-it
Copy link
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 :)

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants