Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #39202
| Path | csiph.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | John-Paul Stewart <jpstewart@personalprojects.net> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: ASCII unicode values |
| Date | Thu, 26 Nov 2020 19:02:51 -0500 |
| Lines | 32 |
| Message-ID | <i2au1bFmburU1@mid.individual.net> (permalink) |
| References | <f0dd6201-439b-4bfa-a5b5-488fdd23e0c2n@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net W01wfg5Ynuk/BCh/B3dGRAFyb68K0QYkrZ/iR05YP8h+yAQBWW |
| Cancel-Lock | sha1:voDrsucOxNf+LDmNFmi6uBbfdxc= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 |
| In-Reply-To | <f0dd6201-439b-4bfa-a5b5-488fdd23e0c2n@googlegroups.com> |
| Content-Language | en-CA |
| Xref | csiph.com comp.lang.javascript:39202 |
Show key headers only | View raw
On 2020-11-26 10:35 a.m., Jonas Thörnvall wrote: > Why does not javascript follow the OS and language implementation of > its reflection on keypresses, why does it use some internal > "charcode?" set where your keypresses do not follow the way you use > them? > > key = e.keyCode ? e.keyCode : e.which; > character= String.fromCharCode(key); You are mixing up keyCodes and charCodes. String.fromCharCode() expects its parameter(s) to be charCode(s), as you should be able to see from the name. Those charCodes are "UTF-16 code units" according to the docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode But what you're passing is a keyCode instead. That is "a system and implementation dependent numerical code identifying the unmodified value of the pressed key" according to its documentation: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode You are clearly very confused since you are passing a system-dependent keyCode to a function that is expecting a UTF-16 charCode. They are not the same thing. You might want key = e.charCode instead. Or, since both charCode and keyCode are deprecated and non-standard, you should probably read up on the key property instead, as was suggested by Michael Haufe in his post to a different thread back on 2020-11-11. https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ASCII unicode values Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-11-26 07:35 -0800
Re: ASCII unicode values Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-11-26 08:15 -0800
Re: ASCII unicode values Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-11-26 12:07 -0800
Re: ASCII unicode values "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-11-26 22:25 +0100
Re: ASCII unicode values Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-11-26 13:46 -0800
Re: ASCII unicode values "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-11-27 00:08 +0100
Re: ASCII unicode values John-Paul Stewart <jpstewart@personalprojects.net> - 2020-11-26 19:02 -0500
Re: ASCII unicode values Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-11-27 10:43 -0800
Re: ASCII unicode values Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-11-28 13:54 -0800
Re: ASCII unicode values luserdroog <luser.droog@gmail.com> - 2020-11-28 18:59 -0800
csiph-web