question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Key event handling

See original GitHub issue

support for combinations and multiple keys for one action.

With the new api it should be possible to pass a single value, an array for multiple possibilities and a combination of keys marked with a plus sign.

Old api:

deleteKeyCode="Backspace"
deleteKeyCode={8}

new api:

deleteKeyCode="Backspace" 
deleteKeyCode={['Backspace', 'Delete']}
deleteKeyCode="Meta+Delete" 

Related: #1269 #1268 #1054 #1002 #1281

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
moklickcommented, Jul 24, 2021

There will be so many changes 😄 Maybe it would be good if we could keep the simple string API (we will already drop the key (number) API). Your idea to use a nested array for combinations is good.

1reaction
mikebarkmincommented, Jul 21, 2021

What about this API?

single: deleteKeyCodes={["Backspace"]}
multiple: deleteKeyCodes={["Backspace", "Delete"]}
combos: deleteKeyCodes={[["Meta", "Delete"]]}

We could even leave deleteKeyCode as is to keep backward compatibility. This also allows for three key combos and should be easier/cleaner to define in TypeScript. But of course we could also use template literal types, if we use your API suggestion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyboardEvent - Web APIs | MDN
KeyboardEvent objects describe a user interaction with the keyboard; each event describes a single interaction between the user and a key ...
Read more >
How to Write a Key Listener
Key events indicate when the user is typing at the keyboard. Specifically, key events are fired by the component with the keyboard focus...
Read more >
The KeyboardEvent
Events that occur when user presses a key on the keyboard, belongs to the KeyboardEvent Object. KeyboardEvent Properties and Methods. Property/Method ...
Read more >
JavaScript Keyboard Events Explained
The keyboard event has two important properties: key and code . The key property returns the character that has been pressed whereas the...
Read more >
Handling Key Events
Cocoa Event Handling Guide · Preparing a Custom View for Receiving Events · Implementing Action Methods · Getting the Location of an Event...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found