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

Keyboard 'enter' fires submit button #30

Open
sbinlondon opened this issue Jul 26, 2018 · 5 comments
Open

Keyboard 'enter' fires submit button #30

sbinlondon opened this issue Jul 26, 2018 · 5 comments
Labels
bug Something isn't working

Comments

@sbinlondon
Copy link
Collaborator

No description provided.

@MissArray
Copy link
Collaborator

Might be able to target the ENTER key by its code (keyCode == 13 for ENTER).

@vlbee
Copy link

vlbee commented Jul 27, 2018

☝️Yes, great suggestion @MissArray. Your use of datalist is great and leverages the accessibility of the HTML5 component. Would be great to get the final bit working. Right now when I hit enter I get rediricted to the query url and see a json object.

@sima-qian sima-qian added the bug Something isn't working label Jul 27, 2018
@MissArray
Copy link
Collaborator

@vlbee, might something like the following work?

var getInput = document.getElementById('input');
input.addEventListener('keyup', function(event) {
//Do we need to prevent default?
if (event.which === 13) {
document.getElementById('submit-button').click();
}
});

@vlbee
Copy link

vlbee commented Jul 27, 2018

@MissArray I'm not sure without looking at the project code again. I'm back mentoring next week and would be happy to look at it with you then during some down time if you like. :)

@MissArray
Copy link
Collaborator

Thanks, Vanessa, that'd be great; it's a useful feature. Have a good weekend and glad to have you back next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants