Special characters not working on html keypress events on OSX

The next page will not work as expected.

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <script src="js/jquery.js"></script>
    </head>
    <body>
        <script>
            $('body').keypress(function(e){
                console.log('char: ',String.fromCharCode(e.keyCode));
            });
        </script>
    </body>
</html>

Attempting to enter special characters, such as á é í ó ú, will print instead a e i o u.

0
source share
1 answer

, jQuery keypress : " :, keypress isn ' t, - , , , , ". : " , , event, . , jQuery .which, ."

Windows, e.which , e.keyCode - . , . ('), A. OSX, , , ; , keydown keyup ( , ).

+1

All Articles