pragma-views2
Version:
41 lines (37 loc) • 858 B
JavaScript
export class BaseShortcuts {
constructor() {
this.keyCodes = {
leftArrow: 37,
rightArrow: 39,
upArrow: 38,
downArrow: 40,
space: 32,
home: 36,
end: 35,
enter: 13
};
}
dispose() {
this.keyCodes = null;
}
/**
* Sets the tabs index to 0 and focuses the element
* @param element
*/
focus(element) {
if (element) {
element.setAttribute("tabindex", "0");
element.focus();
}
}
/**
* Sets tabindex to -1 and removes focus from the element
* @param element
*/
blur(element) {
if (element) {
element.setAttribute("tabindex", "-1");
element.blur();
}
}
}