J
J
JohnDaniels2016-05-07 17:15:17
JavaScript
JohnDaniels, 2016-05-07 17:15:17

How to intercept backspace in Chrome?

There is <div id="transarea" contenteditable="true" >
a need to intercept keystrokes inside it, I do this

$('#transarea')
    .keypress(function(e) {
        if(e.which == 190){ //если нажата точка
            ...............
        }
        if(e.which == 32) { //если нажат пробел
              ................... 
        }
        if(e.which == 8){ //если нажат backspace
            ......................
        }
        else{ // все остальные клавиши
             var symbol = String.fromCharCode(e.which);
            ...............
        }
});

and everything would be fine, but in chrome keypress is suddenly not generated when you click on backspace.
keypress is needed to get Cyrillic characters via String.fromCharCode,
such a number will not work with keyup.
how to be?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Danil Chekalin, 2016-05-07
@dakiesse

The keypress event fires only for character (which output) keys. For Control, Shift, Alt, BackSpace, you need to catch the keydown event

E
Emin, 2015-06-18
@BlobDead

No dependencies needed, read about Swing

D
Dmitry, 2015-06-18
@Venesuella

Download the plugin - called HUY UI Maker)

B
bromzh, 2015-06-18
@bromzh

Look towards JavaFX. There is no graphic editor for it (it is only for the eclipse, it seems), but it's fine without it.
PS There is such a cool thing as ScalaFX . If there are no restrictions on technology, then I advise you to use it. If you are not friends with the rock, then you can use it at least for the graphic part, and for the logic you can take the good old java.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question