Skip to content

Added configurable submitKeys#17058

Open
mirbuf wants to merge 3 commits intoLeaVerou:gh-pagesfrom
mirbuf:gh-pages
Open

Added configurable submitKeys#17058
mirbuf wants to merge 3 commits intoLeaVerou:gh-pagesfrom
mirbuf:gh-pages

Conversation

@mirbuf
Copy link
Copy Markdown

@mirbuf mirbuf commented Apr 11, 2017

Instead of default Enter key, any number of keys can be configured via optional submitKeys: [] array.
Defaults to Comma, Tab and Enter keys.

@LeaVerou
Copy link
Copy Markdown
Owner

Thank you for working on this! I like the flexibility of being able to specify your own keys, that is very on par with Awesomplete's design principles.
However, I still think Enter should be the default. Tab can interfere with tabbing through form controls, and comma could interfere when your actual options contain commas.

@AetherUnbound
Copy link
Copy Markdown

This seems like a great feature, but I agree that having it as default might be problematic. Perhaps it might be made more configurable, i.e. submitKeys initially only contains the enter key but there might also be a method to add one's own preferred default keys.
For instance, we hope to use awesomplete for entering directories. Tabs would be great for that, but perhaps not commas.

@mirbuf
Copy link
Copy Markdown
Author

mirbuf commented Apr 14, 2017

I added submitKeys defaulted that way as a PoC. I agree that could be left just Enter, or Enter + Tab as default keys. And a method to set the new option would be a nice addition. I'll eventually add it, later.

@mirbuf
Copy link
Copy Markdown
Author

mirbuf commented Apr 26, 2017

LeaVerou, I set default submitKeys to [ Enter ].
I also added a method to set user own submitKeys. You can:

setSubmitKeys( KEYCODE )
setSubmitKeys( [ KEYCODE1, ... , KEYCODEn ] )
setSubmitKeys( 'aeiou' ) // this will set 'A', 'E', 'I', 'O', 'U' keys keycodes

Let me know if this may be a more useful addition.

@LeaVerou
Copy link
Copy Markdown
Owner

Why do we need a function (and such a long one at that)? People can modify the submitKeys array, no?

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

Successfully merging this pull request may close these issues.

3 participants