GWT: Incorrect Key Codes Created Using the French Keyboard

On any French keyboard (AZERTY), the point is char '. created using a combination of + , and percent char '%' is generated using a combination of + Shift; Shiftù

Therefore, when I enter one of the above combinations into the GWT text area for writing '.' or "%", the key codes generated for these events are KEY_DELETEin the first case and KEY_LEFTthe last.

TextArea txtArea = new TextArea();
txtArea.addKeyPressHandler(new KeyPressHandler() {
            public void onKeyPress(KeyPressEvent event) {                
                switch (charCode) {
                    case KeyCodes.KEY_LEFT: { // key code 37
                        System.out.write("KEY LEFT");    
                        break;
                    }
                    case KeyCodes.KEY_DELETE: {   // key code 46                   
                         System.out.write("DELETE");
                         break;
                    }
                }

Workaround : get charCode and perform character mapping:

charCode = event.getCharCode();
if (charCode == '.') {...}
else if (charCode == '%') {...} 

Is this a GWT bug? And is there a more elegant way to handle this?

+3
1

, GWT - . 3753 . , , - GWT, , , GWT 2.1 ( , - , , SVN).

+2

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


All Articles