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.

Preventing default up/down key behavior even when no suggestions are available.

See original GitHub issue

Default behavior for pressing the <kbd>up</kbd> and <kbd>down</kbd> keys is being preventDefault’ed, even in cases where the autosuggest does not need to be using special handling for them. In input elements, this manifests as not being able to quickly jump to the beginning and end of an input using these keys, and in textarea and contenteditable elements it prevents jumping between lines.

Single-line Input Reproduction Steps: (Use the Basic example)

  1. Focus the input field.
  2. Type asdf.
  3. Make sure there are no suggestions available.
  4. Press <kbd>up</kbd>.

Observed Behavior: The cursor does not move.

Expected Behavior: The cursor moves to be in front of the first character in the input.

Multi-line Input Reproduction Steps: (Use this codepen)

  1. Focus the input field.
  2. Type asdf.
  3. Press enter to create a new line.
  4. Type asdf again.
  5. Make sure there are no suggestions available.
  6. Press <kbd>up</kbd>.

Observed Behavior: The cursor does not move.

Expected Behavior: The cursor moves to the line above.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
cozmycommented, Sep 2, 2019

@moroshko, do you know when you’d have time to merge @ShibumiGrant’s changes? I also have the same issue and the proposed changes work.

1reaction
moroshkocommented, Mar 10, 2018

Sounds reasonable. Would you like to contribute a PR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you prevent arrow up/down default behaviour in a ...
The input field is single line, so I am using the arrow up/down key to select a suggestion and Enter to insert it....
Read more >
Why has the function of my up & down arrow keys changed ...
Normally, I scroll down a web page a bit at a time using the down arrow key on my laptop keyboard. Since yesterday,...
Read more >
#7639 (Key up/key down in textarea's should optionally not ...
So whenever autocomplete suggestions are not displayed I want user to be able to use arrow keys to serve default behaviour of the...
Read more >
keydown and keyup events do not have proper keyCode (it's ...
3. Press any key. It will always show a keyCode of 0. Expected result: The keydown event should produce a proper keyCode.
Read more >
Windows Terminal Actions | Microsoft Learn
For instance "\u001b[A" will behave as if the up arrow button had been pressed. Command name: sendInput. Default binding: This command is not...
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