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

How to select alt + anykey or shift + anykey ? #144

Closed
rajnishcoder opened this issue Feb 9, 2019 · 4 comments
Closed

How to select alt + anykey or shift + anykey ? #144

rajnishcoder opened this issue Feb 9, 2019 · 4 comments

Comments

@rajnishcoder
Copy link

rajnishcoder commented Feb 9, 2019

Hi, I search but did not found anything and tried the below code but it did not worked.

keyMap = { ALT_ANY: 'alt+*' };

My question is how can I map any key with alt ?
I mean if user press any character key or any key with alt .

for example:- alt+a, alt+b, alt+c, alt+d..... all together in one event.

@greena13
Copy link
Owner

Hi rajnishcoder,

This is an interesting use case and not one that is currently supported by react-hotkeys.

Could you please elaborate on your use-case, so I can make sure there's not an easier way to achieve what you need using react-hotkeys's existing functionality, before I entertain the possibility of adding this functionality.

Thanks.

@rajnishcoder
Copy link
Author

Hi @greena13 ,
Thanks for the reply,

The case is:
I have a blur layer that I want to show on when alt + keydown (not alt + down arrow)
And hide it on alt + keyup or alt+anykey
Because i have 10-15 or more alt+anykey events (on every page) that i want to hide blur layer on those too.

So, the problem is blur layer is working fine on alt keydown and keyup event but, lets say if user pressed alt+a so the blur layer showed up because its alt keydown but did not hide because it is not alt up it is alt+a event that fire,

So, If somehow I can get alt+anykey event i can turn off blur layer on that single event
else
I have to hide it on every alt event on every page of my app, and I feel this is crappy to call it thousands of time.

@rajnishcoder
Copy link
Author

Hey, I just apply this solution for my attach window problem and it resolved this current issue,

after applying this somehow it calls keyup event after alt+anykey so it resolved my problem automatically,

If you know how, I'm just curious to know what is happening ?

@greena13
Copy link
Owner

Hey, I am not sure, as this is in the world of Mousetrap (the latest pre-releases have their own key matching engine that I am more familiar with).

I am not sure if you have stumbled upon some implict behaviour, or whether Mousetrap explicitly supports anykey - currently not in a position to search the source code and find out. I'd be interested to know if this is an explicit usecase, as I'll need to add it to the later versions of react-hotkeys for backwards compatibility.

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

No branches or pull requests

2 participants