IWEdit OnAsyncKeyPress and OnAsyncKeyUp/Down

<< Click to Display Table of Contents >>

Navigation:  Forum >

IWEdit OnAsyncKeyPress and OnAsyncKeyUp/Down

Forum link

 


 

06-10-2021, 08:30 AM:

 

Hi,

 

In IWEdit OnAsyncKeyPress, the value in "EventParams.Values['which']" differs from the value in OnAsyncKeyUp/Down.

 

It looks like another or extended characterset is being used.

 

My problem is, that in OnAsyncKeyPress keys like <Backspace> or <Delete> do not trigger this event.

 

Is this by design, or is this a glitch?

 

Kind regards,

 

Paul

 


 

06-14-2021, 06:13 AM:

 

KeyPress event is only triggered by printable characters (this is part of the DOM specification), so several keys (including Backspace and delete) won't trigger this event. I suggest you try OnAsyncKeyDown event which will work correctly.

 

using EventParams.Values['which'] you will get:

 

Backspace: 8

 

Delete: 46

 


 

06-14-2021, 08:51 AM:

 

Hi Alexandre,

 

I can cope with the fact that KeyPress is only triggered by printable characters.

 

But when I check EventParams.Values['which'] in OnAsyncKeyDown, I get a different value then the key pressed.

 

For example, in OnAsyncKeyDown (and OnAsyncKeyUp), when I press -, the values I get are:

 

which: 189

 

char: ½

 

ansichar: ½

 

But when I check the same in OnAsyncKeyPress, I get the values:

 

which: 45

 

char: -

 

ansichar: -

 


 

06-23-2021, 11:49 AM:

 

(06-14-2021, 08:51 AM)PaulWeem Wrote: [ -> ]Hi Alexandre,

 

I can cope with the fact that KeyPress is only triggered by printable characters.

 

But when I check EventParams.Values['which'] in OnAsyncKeyDown, I get a different value then the key pressed.

 

For example, in OnAsyncKeyDown (and OnAsyncKeyUp), when I press -, the values I get are:

 

which: 189

 

char: ½

 

ansichar: ½

 

But when I check the same in OnAsyncKeyPress, I get the values:

 

which: 45

 

char: -

 

ansichar: -

 

Hi Aleandre,

 

Did you have time to look into this?

 

Kind regards, Paul

 


 

07-08-2021, 07:16 AM:

 

(06-23-2021, 11:49 AM)PaulWeem Wrote: [ -> ] (06-14-2021, 08:51 AM)PaulWeem Wrote: [ -> ]Hi Alexandre,

 

I can cope with the fact that KeyPress is only triggered by printable characters.

 

But when I check EventParams.Values['which'] in OnAsyncKeyDown, I get a different value then the key pressed.

 

For example, in OnAsyncKeyDown (and OnAsyncKeyUp), when I press -, the values I get are:

 

which: 189

 

char: ½

 

ansichar: ½

 

But when I check the same in OnAsyncKeyPress, I get the values:

 

which: 45

 

char: -

 

ansichar: -

 

Hi Aleandre,

 

Did you have time to look into this?

 

Kind regards, Paul

 

?

 


 

07-09-2021, 02:32 AM:

 

Hi Paul, maybe I didn't explain it clearly... I didn't say that you should replace all your OnKeyPress events with OnKeyDown events for all your requirements.

 

They are different events and they behave differently. More importantly:

 

*The keydown and keyup events provide a code indicating which key is pressed, while keypress indicates which character was entered*

 

Please have a look at the spec: https://developer.mozilla.org/en-US/docs...down_event

 

So, don't expect OnKeyDown/Up and OnKeyPress events to receive the same parameters when they are triggered. They won't.