You can get access to Scheduler and its elements via keys or keys' combinations. This article will give you all the necessary information on the peculiarities of keyboard navigation with Scheduler, including focus behavior, usage of ready shortcuts and creation of custom ones.
In order to use keyboard navigation in Scheduler, you need to enable the key_nav extension on the page.
scheduler.plugins({
key_nav: true
});
When the Tab key is pressed, Scheduler gets focus the same as any usual element. After that to navigate Scheduler, you can use the arrow keys and other ones.
When the Tab key is pressed for the second time, the focus leaves Scheduler and is moved to some other place on the page.
When a modal window (a lightbox, a confirm window) opens, the focus moves from the Scheduler to this window and navigation happens inside of it as in a simple form. When the window is closed, focus goes back to the Scheduler.
To return focus back to Scheduler, you need to use the focus method.
scheduler.focus();
When Scheduler gets focus again, it places the focus on the active element inside, or on the first row, or on the latest selected element.
The default navigation actions in a modal window are as follows:
If the focus is set on some button of the form, pressing Space or Enter will call pressing the button under focus and not the action.
When you set focus on a cell it is highlighted in grey/yellow color. If you need to change this style, use the .dhx_focus_slot CSS class:
<style>
.dhx_focus_slot{
background-color: #fff;
}
</style>
An action called on a key click depends on the context. It means that different actions can be attached to different elements (scopes). There are the following context elements (scopes) in Scheduler:
If one and the same shortcut is attached to several scopes, the more specific shortcut will trigger. It means that if the same shortcut is attached to Scheduler and to its element, the shortcut attached to an element will be called rather than the shortcut attached to the whole Scheduler.
To create a new keyboard shortcut, you need to use the addShortcut method and pass three parameters to it:
scheduler.addShortcut("shift+w", function(e){
var target = e.target;
if(target.closest("[event_id]"))
var eventId = target.getAttribute("event_id");
if(eventId)
scheduler.showQuickInfo(eventId);
},"event");
To remove a shortcut from the scope, you need to use the removeShortcut method. The method takes two parameters:
scheduler.removeShortcut("shift+w","event");
You can get the handler of the keyboard shorcut with the help of the method getShortcutHandler. It takes two parameters:
var shortcut_handler = scheduler.getShortcutHandler("shift+w","event");
The method returns a function, which presents the handler of the shortcut call.
A keyboard shortcut can consist of the following keys or key combinations:
There can be several key combinations for one action. In this case, all the combinations are listed with comma delimiter: "ctrl+a, ctrl+space".
There is a set of ready shortcuts that you can use to navigate Scheduler:
Related sample: Keyboard Navigation and WAI-ARIA - Flat Skin
Related sample: Keyboard navigation in the scheduler