kode-team / codemirror-colorpicker

colorpicker with codemirror
https://colorpicker.easylogic.studio/
MIT License
137 stars 13 forks source link

Make colorpicker keyboard-friendly #10

Closed teleclimber closed 5 years ago

teleclimber commented 7 years ago

Now that we can open with Ctrl-K it would be nice if the whole component could be usable with just the keyboard.

I suggest:

Thanks. :)

easylogic commented 7 years ago

@teleclimber

Good ideas!!

I'll implement this function.

teleclimber commented 7 years ago

Glad to hear you're interested in implementing this. However I am not sure that shift+left/right for Hue and ctrl+left/right for alpha is the way that offers the best UX.

Main reasons:

Anyways, just my two cents, but I think using standard keyboard actions is far easier on the user.

easylogic commented 7 years ago

I'm testing some keyboard features, but it's hard to get it right now. I think we need to do more research on the UX side.

I found some facts while testing.

  1. The colorpicker must have the focus unconditionally and be able to receive key events. When you click with a mouse click, the focus does not go out.

  2. When changing the mode through the tab, only the mode will be cycled. Finally, there is no way to get the focus back to the colorpicker.

  3. When keystrokes are input, all events are passed to the colorpicker event handler. So, when you use the key defined in the colorpicker in the input, it behaves unintentionally. For example, when you press the right arrow, the input is the cursor movement, but the colorpicker is the act of changing the main color. This will cause the color at the current input to change.

  4. As you say, you need to know in advance what keystrokes are. This is the most realistic way to switch to Tab mode.

easylogic commented 7 years ago

I made feature/keyboard branch.

https://github.com/easylogic/codemirror-colorpicker/tree/feature/keyboard

I am going to update continues about keyboard feature

easylogic commented 7 years ago

https://store.jui.io/v2/view.php?id=58f8d68594976c182b7b23c7

This is a sample page.

Place your cursor on the code mirror and hit ctrl + K to open the colorpicker popup.

But I still have a lot of problems.

teleclimber commented 7 years ago

On a Mac Ctrl+arrow changes the desktop! So I think using Ctrl+arrow is not going to work.

I agree that doing this in a branch is a good idea.

easylogic commented 7 years ago

@teleclimber

I also added a metakey check.

Now Ctrl + arrow is equals to Cmd + arrow

teleclimber commented 7 years ago

cmd + left is the "back" button in Chrome, Cmd + right is "forward in history".

Have a look at the dev tools keyboard shortcuts to see which ones are likely "safe"

https://developers.google.com/web/tools/chrome-devtools/shortcuts

easylogic commented 7 years ago

CMD + > or CMD + <

How is this?

teleclimber commented 7 years ago

CMD + < opens settings in Chrome.

This is a losing battle IMO. I would use tab key only to navigate to inputs within colorpicker (including sliders and the gradient). And only arrow keys to change the value, with maybe fine grain and coarse grained modifier keys modeled on what detools does.

That way no weird surprises, and easily discoverable for user.

easylogic commented 7 years ago

The tab only specifies the data region and the remainder defines the value with an arrow.

The current focus area should be expressed a little differently.

Good!

easylogic commented 7 years ago

@teleclimber

https://store.jui.io/v2/view.php?id=58f8d68594976c182b7b23c7

I am refactoring for keyboard features.

Tab key is change selection area. Arrow keys is change real value for selection area.

easylogic commented 7 years ago

colorpicker-with-keyboard

This is a sample move patterns.

Mottie commented 7 years ago

The "HEX" mode works great if you have the outer wrapper focused, but if you focus the hex input, the movement and color selection is awkward.