selecto icon indicating copy to clipboard operation
selecto copied to clipboard

Start selecting only on key press.

Open Mako-L opened this issue 2 years ago • 1 comments

Environments

  • Framework name:react
  • Framework version:latest
  • Component name: react-selecto
  • Component version: 1.12.0
  • Testable Address(optional):

Description

Is there a way to start selection only on keypress? For example, I want to start selecting only when I have the ctrl key pressed, not all the time.

Mako-L avatar Aug 18 '21 15:08 Mako-L

@Mako-L

Let's take the keycon module as an example.

If the ctrl key is not pressed, call the stop function in the onDragStart event.

import KeyController from "keycon";

const keycon = new KeyController();

<Selecto
onDragStart={e => {
   if (!keycon.ctrlKey) {
      e.stop();
      return;
   }
}};

daybrush avatar Sep 11 '21 03:09 daybrush