DayPilot.Scheduler.onKeyboardFocusChange

The onKeyboardFocusChange event handler fires when the keyboard focus is about to change, either after the user presses an arrow key or when keyboard.move() is called.

It is called before the actual focus change, and you can cancel the change using args.preventDefault().

Available since 2021.3.5075.

Declaration

DayPilot.Scheduler.onKeyboardFocusChange(args)

Parameters

  • args.focus - the new focus target (not yet active)

  • args.previous - the current focus target

  • args.preventDefault() - cancels the default action for the Escape and Enter keys

Notes

The args.focus and args.previous properties use the same focus object structure as keyboard.getFocus(). This event lets you inspect the pending focus target and keep the current one by calling args.preventDefault() before the change is applied.

Examples

JavaScript

const dp = new DayPilot.Scheduler("dp", {
  onKeyboardFocusChange: (args) => {
    console.log("Keyboard focus is about to change", args.previous, args.focus);
    // Call args.preventDefault() here to keep the current focus target.
  },
  // ...
});
dp.init();

Angular

<daypilot-scheduler [config]="config"></daypilot-scheduler>
config: DayPilot.SchedulerConfig = {
  onKeyboardFocusChange: (args) => {
    console.log("Keyboard focus is about to change", args.previous, args.focus);
    // Call args.preventDefault() here to keep the current focus target.
  },
  // ...
};

React

<DayPilotScheduler
  onKeyboardFocusChange={onKeyboardFocusChange}
  {/* ... */}
/>
const onKeyboardFocusChange = (args) => {
  console.log("Keyboard focus is about to change", args.previous, args.focus);
  // Call args.preventDefault() here to keep the current focus target.
};

Vue

<DayPilotScheduler
  @keyboardFocusChange="onKeyboardFocusChange"
  <!-- ... -->
/>
const onKeyboardFocusChange = (args) => {
  console.log("Keyboard focus is about to change", args.previous, args.focus);
  // Call args.preventDefault() here to keep the current focus target.
};

See Also

Keyboard Support [doc.daypilot.org]

DayPilot.Scheduler.keyboard.move()

DayPilot.Scheduler.keyboard.getFocus()

DayPilot.Scheduler.onKeyboardFocusChanged

DayPilot.Scheduler Class

Availability

Availability of this API item in DayPilot editions:

LitePro
DayPilot for JavaScript