I’ve set up a simple drag and drop where theres 3 draggables and 3 droppables. I’m trying to change the default keyboard behaviour – however I’ve tried to intercept the KeyboardSensor and it seems that I can’t change the behavior for the space and enter keys – they don’t even register in the code:
import {
MouseSensor as LibMouseSensor,
KeyboardSensor as LibKeyboardSensor
} from '@dnd-kit/core';
function shouldHandleEvent(element) {
let cur = element;
return cur.dataset.noDnd === 'true';
}
export class MouseSensor extends LibMouseSensor {
static activators = [
{
eventName: 'onMouseDown',
handler: ({ nativeEvent: event }) => {
return shouldHandleEvent(event.target);
}
}
];
}
export class KeyboardSensor extends LibKeyboardSensor {
static activators = [
{
eventName: 'onKeyDown',
handler: () => {
return true;
}
}
];
}