Thanks for a prompt answer.
There is only one thing I don't understand: provided solution doesn't work for shift-tab.
For some reason prevCell.editMode is false in the case despite it was in the mode.