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

Apply a suggestion on comma key pressed #206

Open
ghost opened this issue May 11, 2016 · 6 comments
Open

Apply a suggestion on comma key pressed #206

ghost opened this issue May 11, 2016 · 6 comments

Comments

@ghost
Copy link

ghost commented May 11, 2016

It would be great if UI will apply a suggesstion when comma pressed as like it works now with enter key.

For example, typing "jav,gr,int,win," will select Java, Gradle, IntelliJ and Windows.

I know one can use enter key for that, this just a small additional convenience for users :)

@joeblau
Copy link
Collaborator

joeblau commented May 20, 2016

I played with this for a little bit a few days ago; there is no quick parameter that can be set in Select2 that enables this. This can be done, but it requires listening to select2 events and manually triggering the effect.

@joeblau
Copy link
Collaborator

joeblau commented Feb 14, 2017

I re-looked into this when I was updating the site. Select 2 has a way to use arbitrary keys to select a tag, but that seems to just act as pressing down and not as pressing enter. I'll keep looking into whether or not this is possible.

@Plloi
Copy link

Plloi commented Jan 10, 2018

Too lazy to fork... but you can add a new if here to listen for key code 188 (or whatever other keys you want) and select with $(".ignore-search").data('select2').results.trigger('results:select')
you will want to preventDefault on that event as well.

EDIT: not in that handler, but that bit of code will trigger selection

@Plloi
Copy link

Plloi commented Jan 10, 2018

$(".ignore-search").on("select2:open", _=>{
    $(".select2-search__field").keydown(e=>{
        if ($(".ignore-search").data('select2').$results.attr('aria-expanded') === "true" && e.keyCode==188){
          $(".ignore-search").data('select2').results.trigger('results:select');
          e.preventDefault();
        }
    });
});

That should do it.

@Aidateck
Copy link

J'ai des difficulté avec Github.
Je suis encore un novice en ce qui concerne le codage et j'avoue avoir de grande difficulté a mettre en œuvre les conseils de Github ou les tuto sur cette application de codage.
Je vais metre du temps a comprendre et a utiliser Github comme il ce dois.
Merci a vous et bonne année 2022

@github-actions
Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants