diff --git a/.changeset/end-on-tab.md b/.changeset/end-on-tab.md new file mode 100644 index 00000000..08e118bc --- /dev/null +++ b/.changeset/end-on-tab.md @@ -0,0 +1,5 @@ +--- +'@dnd-kit/core': patch +--- + +Added `Tab` to the list of default key codes that end a drag and drop operation. Can be customized by passing in a custom list of `keyCodes` to the KeyboardSensor options. diff --git a/packages/core/src/sensors/keyboard/defaults.ts b/packages/core/src/sensors/keyboard/defaults.ts index ec469808..3026f102 100644 --- a/packages/core/src/sensors/keyboard/defaults.ts +++ b/packages/core/src/sensors/keyboard/defaults.ts @@ -3,7 +3,7 @@ import {KeyboardCoordinateGetter, KeyboardCode, KeyboardCodes} from './types'; export const defaultKeyboardCodes: KeyboardCodes = { start: [KeyboardCode.Space, KeyboardCode.Enter], cancel: [KeyboardCode.Esc], - end: [KeyboardCode.Space, KeyboardCode.Enter], + end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab], }; export const defaultKeyboardCoordinateGetter: KeyboardCoordinateGetter = ( diff --git a/packages/core/src/sensors/keyboard/types.ts b/packages/core/src/sensors/keyboard/types.ts index 635fdbda..1d0f29cd 100644 --- a/packages/core/src/sensors/keyboard/types.ts +++ b/packages/core/src/sensors/keyboard/types.ts @@ -9,6 +9,7 @@ export enum KeyboardCode { Up = 'ArrowUp', Esc = 'Escape', Enter = 'Enter', + Tab = 'Tab', } export type KeyboardCodes = {