mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2013
Posts: 3
D
Dj328i Offline OP
Self-satisified door
OP Offline
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 !!!

Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
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.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
$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

Joined: Apr 2018
Posts: 83
E
Babel fish
Offline
Babel fish
E
Joined: Apr 2018
Posts: 83
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


Link Copied to Clipboard