jaredreich / pell

📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies
MIT License
11.95k stars 549 forks source link

Map hotkeys to actions #6

Open PaulBGD opened 7 years ago

PaulBGD commented 7 years ago

Such as Control + b to bold. It'd be useful to make this configurable.

CodeBrauer commented 7 years ago

I would also like to see more common shortcuts like CMD+K for links and also I would include the keymap in the buttons title attribute so users can find out what shortcuts are available: bildschirmfoto 2017-07-11 um 10 08 10

hackape commented 7 years ago

Guys, please check out the src/ and you'll see why it's so light weighted. It's only 100+ lines of code.

I think the whole point of this lib is to demonstrate how simple wyswyg can be done with modern browser APIs. Feature request like this should be done by some plugin, not included in core lib.

ZWkang commented 7 years ago

maybe if you want to use such as control+b ,maybe you can try to listen keydown and trigger the editor action

hackape commented 7 years ago

Integration with mousetrap: https://jsfiddle.net/hackape/jpffb9f5/

One interesting thing I found while making the demo, browsers actually implement some default hotkeys, but just not consistently. I tested on Chrome and Firefox, macOS version. Firefox implements cmd/ctrl+b/i/u as expected, while Chrome implements weirdly just cmd+b, cmd+i, ctrl+u.