mIRC Home    About    Download    Register    News    Help

Print Thread
Same ascii code for two keys on $keyval #264790
12/01/19 09:11 AM
12/01/19 09:11 AM
Joined: Aug 2013
Posts: 3
D
Dj328i Offline OP
Self-satisified door
Dj328i  Offline OP
Self-satisified door
D

Joined: Aug 2013
Posts: 3
Hi !

I wrote a script on draw with an event on DEL keyup

I was surprised to see that it did not work on first try

The resultat was because the DEL key return ascii code "46" instead of "127"

46 is the ascii code for dot, so the event occur when i press del and dot grin

I hope you will change it in the next version ( oh and i'm on the 7.52 )

Thank you in advance !!!

Re: Same ascii code for two keys on $keyval [Re: Dj328i] #264791
12/01/19 09:39 AM
12/01/19 09:39 AM
Joined: Aug 2003
Posts: 227
UK
P
Protopia Offline
Fjord artisan
Protopia  Offline
Fjord artisan
P

Joined: Aug 2003
Posts: 227
UK
I think that key values are not the same as the ASCII character value. In other words, $keyval does not return an ascii code, but instead a different number identifying the key.

Re: Same ascii code for two keys on $keyval [Re: Dj328i] #264792
12/01/19 09:50 AM
12/01/19 09:50 AM
Joined: Jan 2004
Posts: 1,158
maroon Offline
Hoopy frood
maroon  Offline
Hoopy frood

Joined: Jan 2004
Posts: 1,158
$keyval returns the key CODE, if you want the key CHAR you should be using $keychar. There's a lot more collisions for other non-text keys like PageUp PageDn etc. F10 has same the same $keyval as 'x', but returns $keychar as $null instead of as 'x'.

Also, mIRC maps $keycode 127 to Ctrl+Backspace (delete word left) with $keychar also being $chr(127). Search the forum for the /sendkeys alias, and you'll find that this behaves like delete-word-left:

Code:
//sendkeys abcd DeletesThisWord $+ $chr(127) efgh

Re: Same ascii code for two keys on $keyval [Re: Dj328i] #264955
04/02/19 02:42 PM
04/02/19 02:42 PM
Joined: Apr 2018
Posts: 76
E
Erasimus Offline
Babel fish
Erasimus  Offline
Babel fish
E

Joined: Apr 2018
Posts: 76
Just my thoughts (just as invalid as anyone else's)
Quote:
The resultat was because the DEL key return ascii code "46" instead of "127"
46 is the ascii code for dot, so the event occur when i press del and dot grin


On any keyboard I have seen that key will be used for dot and del, dependant upon the state of the NumLock state. There is normally also another del key called Delete (in the insert, home, pg up etc. cluster above the arrow keys on my keyboard). I think laptops also have a separate del key, position changes from manufacturer to manufacturer.

In other words with numlock off both del keys would give the same ASCII code, but differ with numlock on. Note Keycode (where key is on the keyboard matrix) and ASCII key code are not the same thing

Could this be the source of the confusion