fgr-araujo / vue-shortkey

Vue-ShortKey - The ultimate shortcut plugin to improve the UX
MIT License
884 stars 101 forks source link

Add "regions" so hotkeys can only be triggered when elements within a region have focus #87

Open Soviut opened 5 years ago

Soviut commented 5 years ago

Imagine you have several lists, each one with an "Add Item" button. You want a hotkey for each list to trigger the addItem() method. The problem is, hotkeys are global, so which list would have an item added to it?

This could be solved by the ability to define "regions". If any child elements within a region have focus, the hotkey will be localized. So in our list example, only when a list has focus would the hotkey create a new item for that specific list.

<div v-shortkey-region="someRegion">
  <input v-for="item in items" type="text" v-model="...">
  <button @v-shortkey="['ctrl' + 'alt' + 'n']" v-shortkey-parent-region="someRegion">Add Item</button>
</div>

Consider this an extremely rough proposal. Naming conventions, syntax and implementation are all just for demonstration purposes.

fgr-araujo commented 5 years ago

It's really good idea!!