Delete on Keyboard should remove rows and move the next row to the top

Tags: #<Tag:0x00007f8b2597d7b0>

Hi,

I am trying to delete rows by selecting and then press Delete key on Keyboard. Its wiping off the content in each cell for 3 rows ,but it’s not moving next row to first.

e.g. I have 5 rows. I selected first 3 rows and press Delete. it should move the 4th row to the top or first row. But it’s not.
It should exactly behave as “remove rows” when we right click and select remove rows.

please help!

Thank you.

Welcome @kirank.csp

you can change the logic of keys via afterDocumentKeyDown hook. To get the range of cells you can use getSelectedLast() method and an alter() method to remove the rows.

Thank you so much for your reply. Yes I made it work. used beforeKeyDown function to prevent Delete and backspace keys.

beforeKeyDown = function (event) {
if (event.keyCode === 8 || event.keyCode === 46) {
Handsontable.dom.stopImmediatePropagation(event);
}
};

1 Like

Great. Thank you for a quick update.

We can close the topic.