IcarusWorks / ember-key-manager

A service for (un)binding keyboard up and down events.
MIT License
42 stars 11 forks source link

Clearer, less confusing API #30

Closed gossi closed 6 years ago

gossi commented 6 years ago

The current API is a bit confusing when it comes to modifiers that are optional or required.

I just post some examples and what I would expect:

addMacro({
  keys: ['a', 'ctrl'],
  modifierKeys: ['alt']
});

fires on ctrl + a as well as on alt + ctrl + a

addMacro({
  keys: ['a'],
  modifierKeys: ['ctrl', 'alt']
});

fires on a as well as on ctrl + a and alt + a. Question is on ctrl + alt + a yes or no?

Derieved rules:

Maybe not just limiting the optional keys to modifiers? E.g.

addMacro({
   required: ['a', 'alt'],
   optional: ['ctrl', 'f']
});

After all would open up the API to be less restricting or limiting and will leave the choice and freedom to the developer.

jordpo commented 6 years ago

I feel like this would increase the complexity greatly. Any reason to not just register multiple callbacks with the correct key combinations?

gossi commented 6 years ago

What I'm after is more like that fact, you currently have to deal with some confusing things:

  1. Control vs ctrlKey - why two different keywords for the same button?
  2. There is executionKey and modifierKeys - where do I need to put which keyword mentioned in (1) if I just want to trigger on a modifier key?
  3. executionKey only allows for one key to trigger a macro, which is limiting

These are the pain points of the current API as I see them.

patrickberkeley commented 6 years ago

There are separate issues here. I'm going to split them up and close this issue.

  1. Control vs ctrlKey - why two different keywords for the same button? – #36
  2. There is executionKey and modifierKeys - where do I need to put which keyword mentioned in (1) if I just want to trigger on a modifier key? – related to #24, #35
  3. executionKey only allows for one key to trigger a macro, which is limiting – #28