mIRC Home    About    Download    Register    News    Help

Topic Options
#264790 - 12/01/19 09:11 AM Same ascii code for two keys on $keyval
Dj328i Offline
Self-satisified door

Registered: 02/08/13
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 !!!

Top
#264791 - 12/01/19 09:39 AM Re: Same ascii code for two keys on $keyval [Re: Dj328i]
Protopia Offline
Fjord artisan

Registered: 30/08/03
Posts: 225
Loc: 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.

Top
#264792 - 12/01/19 09:50 AM Re: Same ascii code for two keys on $keyval [Re: Dj328i]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1139
$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

Top
#264955 - 04/02/19 02:42 PM Re: Same ascii code for two keys on $keyval [Re: Dj328i]
Erasimus Offline
Babel fish

Registered: 26/04/18
Posts: 72
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

Top