Keyboard API: Cannot read properties of null (reading 'keyboard')
4 years ago.
Hi,
I'm using the following code from this tutorial (https://code.daypilot.org/68177/javascript-scheduler-how-to-use-the-keyboard-api)
onKeyDown: args => {
if (args.originalEvent.code === "Tab") {
args.originalEvent.preventDefault();
if (args.originalEvent.shiftKey) {
this.scheduler.control.keyboard.move("left");
} else {
this.scheduler.control.keyboard.move("right");
}
}
},
onEventEditKeyDown: args => {
if (args.originalEvent.code === "Tab") {
args.originalEvent.preventDefault();
args.originalEvent.stopPropagation();
args.submit();
if (args.originalEvent.shiftKey) {
this.scheduler.control.keyboard.move("left");
}
else {
this.scheduler.control.keyboard.move("right");
}
}
},
If I press the arrow or tab keys, I'm getting this error:
logging.service.ts:11
TypeError: Cannot read properties of null (reading 'keyboard')
at DayPilot.Scheduler.onKeyDown (time-reporting-board.component.ts:294)
at HTMLDocument.<anonymous> (daypilot-core.js:35)
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:41686)
at ZoneDelegate.invokeTask (zone-evergreen.js:398)
at Zone.runTask (zone-evergreen.js:167)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:480)
at invokeTask (zone-evergreen.js:1621)
at HTMLDocument.globalZoneAwareCallback (zone-evergreen.js:1658)
DayPilot