How to capture backspace key code in android - javascript browser?

I have a page written in pure Javascript HTML ... I am processing the activation code and I need to get the key code when I need to perform the special task key code == 8 (backspace) ... but if I open the page in the Android browser, chrome or something else ... backspace does not return any key code ...

I did:

$( '.input-cell' ).bind( 'keyup', function( e ){ var keycode = e.keyCode ? e.keyCode : e.which; alert( keycode ); if( keycode == 8 ) { ..... } }); 

The warning returns all key codes to me, but backspace ... is there a way to capture an event to return to the past?

+4
source share
2 answers

input change event

 $('#myinput').bind('input', function(){ // code }); 

Backspace

 $('#myinput').on('keypress', function() { //code }).on('keydown', function(e) { if (e.keyCode==8) { //code } }); 
+2
source
 if (e.keyCode == 8 || e.keyCode == 229) { // code } 
0
source

Source: https://habr.com/ru/post/1500331/


All Articles