Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #39196 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2020-11-26 07:35 -0800 |
| Last post | 2020-11-28 18:59 -0800 |
| Articles | 10 — 4 participants |
Back to article view | Back to comp.lang.javascript
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
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-11-26 07:35 -0800 |
| Subject | ASCII unicode values |
| Message-ID | <f0dd6201-439b-4bfa-a5b5-488fdd23e0c2n@googlegroups.com> |
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); In 99.999% of programming cases people probably want the mapping to be done just how the keyboard usually work within OS? And if i as programmer can do the mapping, why is it not an option to chose "a natural" mapping, that actually reflect "how the OS" does it? Every project that use keyboard input have to write the same/similar mapping code? Isn't that rather ridiculous? Use the OS ,mapping seem to me to be less job to implement, then the awkward way it is implemented now?
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-11-26 08:15 -0800 |
| Message-ID | <de56de23-8ae2-45fb-b0e6-a0b00a652da6n@googlegroups.com> |
| In reply to | #39196 |
torsdag 26 november 2020 kl. 16:35:08 UTC+1 skrev Jonas Thörnvall: > 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); > > In 99.999% of programming cases people probably want the mapping to be done just how the keyboard usually work within OS? > > And if i as programmer can do the mapping, why is it not an option to chose "a natural" mapping, that actually reflect "how the OS" does it? > > Every project that use keyboard input have to write the same/similar mapping code? Isn't that rather ridiculous? > > Use the OS ,mapping seem to me to be less job to implement, then the awkward way it is implemented now? Probably should said i am talking about the charcodes catched when you press a key, and echo them back. Why isn't it the same as for example the textarea or text input in HTML why does not the charcodes reflect those.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-11-26 12:07 -0800 |
| Message-ID | <2791570a-0b97-4ed5-b0df-093f8f47c0fcn@googlegroups.com> |
| In reply to | #39197 |
torsdag 26 november 2020 kl. 17:15:48 UTC+1 skrev Jonas Thörnvall: > torsdag 26 november 2020 kl. 16:35:08 UTC+1 skrev Jonas Thörnvall: > > 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); > > > > In 99.999% of programming cases people probably want the mapping to be done just how the keyboard usually work within OS? > > > > And if i as programmer can do the mapping, why is it not an option to chose "a natural" mapping, that actually reflect "how the OS" does it? > > > > Every project that use keyboard input have to write the same/similar mapping code? Isn't that rather ridiculous? > > > > Use the OS ,mapping seem to me to be less job to implement, then the awkward way it is implemented now? > Probably should said i am talking about the charcodes catched when you press a key, and echo them back. > Why isn't it the same as for example the textarea or text input in HTML why does not the charcodes reflect those. Right now i am remapping the numeric keyboard, but 3 and 9, also has a behaviour of PgUp PgDown, is it possible to redirect this behaviour "remove it". Is that OS behaviour or browser application behaviour?
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2020-11-26 22:25 +0100 |
| Message-ID | <XnsAC81E426DDEA4eejj99@194.109.6.166> |
| In reply to | #39197 |
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 26 Nov 2020 in comp.lang.javascript: > Probably should said i am talking about the charcodes catched when you > press a key, and echo them back. I tried this, but the keyboard gets no echo back, even with my ear on the board. In fact, the keyboard does not produce charcodes, it only reports the changes in status of its keys to the operating system. > Why isn't it the same as for example > the textarea or text input in HTML why does not the charcodes reflect > those. What an unintelligable question. A textarea has no keys. I don't know what should what reflect. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-11-26 13:46 -0800 |
| Message-ID | <89b47b9f-2cfd-4ef3-a89f-b545b61b77c9n@googlegroups.com> |
| In reply to | #39199 |
torsdag 26 november 2020 kl. 22:25:52 UTC+1 skrev Evertjan.: > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.t...@gmail.com> wrote on 26 > Nov 2020 in comp.lang.javascript: > > Probably should said i am talking about the charcodes catched when you > > press a key, and echo them back. > I tried this, but the keyboard gets no echo back, > even with my ear on the board. > > In fact, the keyboard does not produce charcodes, it only reports the > changes in status of its keys to the operating system. > > Why isn't it the same as for example > > the textarea or text input in HTML why does not the charcodes reflect > > those. > What an unintelligable question. A textarea has no keys. > > I don't know what should what reflect. > > -- > Evertjan. > The Netherlands. > (Please change the x'es to dots in my emailaddress) Well i am telling you that the charcodes fetched by javascript, when echoed on canvas "for example", do not match what is echoed in a textarear or input field. And i wonder why not the principles of what is reflected out not the same.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2020-11-27 00:08 +0100 |
| Message-ID | <XnsAC8215DD24B0eejj99@194.109.6.166> |
| In reply to | #39200 |
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 26 Nov 2020 in comp.lang.javascript: > torsdag 26 november 2020 kl. 22:25:52 UTC+1 skrev Evertjan.: >> <jonas.t...@gmail.com> wrote on 26 Nov 2020 in comp.lang.javascript: >> > Probably should said i am talking about the charcodes catched when >> > you press a key, and echo them back. >> I tried this, but the keyboard gets no echo back, >> even with my ear on the board. >> >> In fact, the keyboard does not produce charcodes, it only reports the >> changes in status of its keys to the operating system. >> > Why isn't it the same as for example >> > the textarea or text input in HTML why does not the charcodes reflect >> > those. >> What an unintelligable question. A textarea has no keys. >> >> I don't know what should what reflect. > Well i am telling you that the charcodes fetched by javascript, What Javascript command fetches charcodes? Remember, that Javascript is a language prompting an engine to do something, Javascript itself doesn't 'do' a damned thing. > when > echoed on canvas "for example", do not match what is echoed in a > textarear or input field. Is "telling you" usefull?? Wouldn't it be better to write an [SMALL!] example in code to show the perceived problem to us? > And i wonder why not the principles of what > is reflected out not the same. What principles are you talking about? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | John-Paul Stewart <jpstewart@personalprojects.net> |
|---|---|
| Date | 2020-11-26 19:02 -0500 |
| Message-ID | <i2au1bFmburU1@mid.individual.net> |
| In reply to | #39196 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-11-27 10:43 -0800 |
| Message-ID | <6abb2506-06e7-415b-be50-f6e746a755dcn@googlegroups.com> |
| In reply to | #39202 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-11-28 13:54 -0800 |
| Message-ID | <bc5fb0a6-0110-4d91-94ad-d55f38b04b9an@googlegroups.com> |
| In reply to | #39209 |
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
[toc] | [prev] | [next] | [standalone]
| From | luserdroog <luser.droog@gmail.com> |
|---|---|
| Date | 2020-11-28 18:59 -0800 |
| Message-ID | <18c3ebfb-3e43-4401-b8d3-79fd3c19ca04n@googlegroups.com> |
| In reply to | #39217 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web