Hi Aleksandra,
I finally found some time to implement it. Your recommendations helped a lot!
If anybody is interested, this is my current solution:
private handledKeys = ['ArrowLeft', 'ArrowRight'];
onBeforeKeyDown = (event) => {
if (this.hot.getSelected() && event['ctrlKey'] && this.handledKeys.includes(event['key'])) {
event.stopImmediatePropagation();
}
}
onAfterDocumentKeyDown = (event) => {
if (this.hot.getSelected() && event['ctrlKey'] && this.handledKeys.includes(event['key'])) {
let row = this.hot.getSelected()[0][0];
let column = this.hot.getSelected()[0][1];
const totalCols = this.hot.countCols();
const right = (event['key'] === 'ArrowRight');
const left = (event['key'] === 'ArrowLeft');
if (right || left) {
const incr = right ? 1 : -1;
do {
column = this.mod(column + incr, totalCols);
} while(this.emptyOrNoWidth(row, column));
this.hot.selectCell(row, column);
}
}
};
...
hotSettings.afterDocumentKeyDown = this.onAfterDocumentKeyDown;
hotSettings.beforeKeyDown = this.onBeforeKeyDown;
...
private emptyOrNoWidth(row:number, col:number):boolean {
return this.hot.getColWidth(col) < 1 || !this.hot.getDataAtCell(row, col);
}
public static mod(n:number, m:number):number {
return ((n % m) + m) % m;
}