Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #39218
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2020-11-28 18:59 -0800 |
| References | <f0dd6201-439b-4bfa-a5b5-488fdd23e0c2n@googlegroups.com> <i2au1bFmburU1@mid.individual.net> <6abb2506-06e7-415b-be50-f6e746a755dcn@googlegroups.com> <bc5fb0a6-0110-4d91-94ad-d55f38b04b9an@googlegroups.com> |
| Message-ID | <18c3ebfb-3e43-4401-b8d3-79fd3c19ca04n@googlegroups.com> (permalink) |
| Subject | Re: ASCII unicode values |
| From | luserdroog <luser.droog@gmail.com> |
On Saturday, November 28, 2020 at 3:54:43 PM UTC-6, jonas.t...@gmail.com wrote: > fredag 27 november 2020 kl. 19:43:58 UTC+1 skrev Jonas Thörnvall: > > fredag 27 november 2020 kl. 01:03:01 UTC+1 skrev John-Paul Stewart: > > > 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 > > Honestly i have better things todo then reading up on things to soon be replaced and depercated.... > > I rather sit remap the shit they produced so far, then learn some new shit syntax that produce same shit out that soon will be replaced and deprecated as soon next anal monkey get the hands on the codebase, "having new and better ideas" LoL. > Apparently i am not the only one that is confused by how they have implemented this, it is kind of fucking weird that you do not get the value of the keypressed... > https://stackoverflow.com/questions/1772179/get-character-value-from-keycode-in-javascript-then-trim It's weird at any level, but yeah, javascript inherits weirdnesses in this area from all the levels below it and all the backported hacks from JScript and other incompatible extensions. Stick to the latest standard that is supported on your target machines and try to ignore the krufty bits.
Back to comp.lang.javascript | Previous | Next — Previous 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