ref.current.addEventListener('keydown', function(e) {
...
I am able to detect backspace using e.code === 'Backspace' but I want to know at which character position its pressed. for example, the input is 123 and the cursor is behind 3 (backspace is pressed to delete 3). or cursor is in front of 1 so backspace is pressed to delete nothing. thanks