N
The Daily Insight

What is the keyCode for backspace in JavaScript?

Author

Christopher Pierce

Updated on April 22, 2026

8
Keycode values

KeyCode
backspace8
tab9
enter13
shift16

How do you use backspace in JavaScript?

You can capture a backspace key on the onkeydown event. Once you get the key of pressed button, then match it with the Backspace key code. A Backspace key keycode it 8. Use keydown instead of keypress .

What charCode 45?

7 Answers. The JavaScript charCodes, which you test for during a keypress event, are ASCII. 109 is the correct keyCode, if used in a keydown or keyup event. “-” has a charCode of 45.

What is the character code for Backspace?

08
Pressing the backspace key on a computer terminal would generate the ASCII code 08, BS or Backspace, a control code which would delete the preceding character. That control code could also be accessed by pressing Control-H, as H is the eighth letter of the Latin alphabet.

How do you give Backspace in HTML?

6 Answers. HTML is stateless, so there is no possibility of backspace functionality with HTML alone. You could do something with javascript to achieve a similar effect. Another approach, would be to buffer your output before sending it, and then process the buffered output.

What are UTF 16 characters?

UTF-16 (16-bit Unicode Transformation Format) is a character encoding capable of encoding all 1,112,064 valid character code points of Unicode (in fact this number of code points is dictated by the design of UTF-16). The encoding is variable-length, as code points are encoded with one or two 16-bit code units.

What can I use instead of keyCode in JavaScript?

keyCode is now deprecated. We now have a better alternative: KeyboardEvent. key that displays whatever characters we type on an input without caring about the type of keyboard layout that we are currently using.

What can I use instead of backspace?

ctrl-w to erase the last word, ctrl-u to erase the entire line you’re on. In insert mode ctrl+h does the same thing as the backspace key (i.e. deletes one character backwards).

Can you backspace a typewriter?

On a real typewriter, backspace simply moves the carriage back one space, allowing you to overtype a previously typed character. Erasing requires Tipp-Ex or suchlike.