chieffancypants / angular-hotkeys

Configuration-centric keyboard shortcuts for your Angular apps.
http://chieffancypants.github.io/angular-hotkeys/
MIT License
1.68k stars 248 forks source link

Cheatsheet sorting #194

Open madks13 opened 8 years ago

madks13 commented 8 years ago

In the project i'm working on, the hotkeys are added dynamically and statically (a few static hotkeys, 2 lists each containing elements that can have combos to apply to). The problem with adding hotkeys dynamically is that they are not sorted. For example :

When cheatsheet is displayed, they are all displayed in the order they were added. I haven't found a way to sort the resulting cheatsheet list from the documentation.

Is it possible to add sorting of hotkeys by combo and/or description?

theclapp commented 8 years ago

If you're willing to tweak the cheatsheet template, you can sort the hotkeys (I would think; haven't tried it). The project homepage documents the template (briefly).

(As an aside, if you're willing to tweak the template, you can do a lot of stuff that people ask for regarding it. Sort, scroll, multiple columns, etc. (Well, to be clear, I've only tried multiple columns, but you get the idea.))

I haven't tried this either, but it looks like if you call hotkeys.get() (with no arguments), you'll get back the whole hotkeys array. If you sort it in place (which Array.sort() does), that might also do what you want. Whether this breaks anything else is left as an exercise. :)

madks13 commented 8 years ago

Well, i don't mind tinkering with libraries i use. I have changed Chocolat library to add a few features i needed for the project, but if possible i'd also like to see those features be implemented in the library officially since they're very helpful.