899 B
899 B
Requested features - immediately brought to life by a bit of code
Saving the current color and closing the popup on Enter
(#187)
pickr.on('init', instance => {
// Grab actual input-element
const {result} = instance.getRoot().interaction;
// Listen to any key-events
result.addEventListener('keydown', e => {
// Detect whever the user pressed "Enter" on their keyboard
if (e.key === 'Enter') {
instance.applyColor(); // Save the currently selected color
instance.hide(); // Hide modal
}
}, {capture: true});
});
Feel free to submit a PR or create an issue if you got any ideas for more examples!