EVT_KEY_PRESS problem (HOLD) | developer.brewmp.com EVT_KEY_PRESS problem (HOLD) | developer.brewmp.com

Developer

EVT_KEY_PRESS problem (HOLD)

Forums:

Hello there,

When I hold the AVK_SELECT on the device it doesn't call the Function(pApp); It calls it just once a hold.

What's wrong with the code ?

switch (eCode)
{
case EVT_KEY_PRESS:
switch(wParam)
{
case AVK_SELECT: Function(pApp);

return TRUE;
}
return TRUE;

Thx :)

probably EVT_KEY will be better for you

probably EVT_KEY will be better for you

The problem is that I really need to use EVT_KEY_PRESS or another event which allows me to send events while holding an specific key...

The problem is that I really need to use EVT_KEY_PRESS or another event which allows me to send events while holding an specific key...

allows you to send events? or sends events to you while user is holding the key?
EVT_KEY_PRESS is called only once - when the user pushes the button.
EVT_KEY is sent with a certain rate repeatedly while user is holding. Or you may want to handle both EVT_KEY_PRESS and EVT_KEY_RELEASE and set a timer on a EVT_KEY_PRESS to call your function while EVT_KEY_RELEASE is not received.

allows you to send events? or sends events to you while user is holding the key?
EVT_KEY_PRESS is called only once - when the user pushes the button.
EVT_KEY is sent with a certain rate repeatedly while user is holding. Or you may want to handle both EVT_KEY_PRESS and EVT_KEY_RELEASE and set a timer on a EVT_KEY_PRESS to call your function while EVT_KEY_RELEASE is not received.

archi wrote:allows you to send events? or sends events to you while user is holding the key?
EVT_KEY_PRESS is called only once - when the user pushes the button.
EVT_KEY is sent with a certain rate repeatedly while user is holding. Or you may want to handle both EVT_KEY_PRESS and EVT_KEY_RELEASE and set a timer on a EVT_KEY_PRESS to call your function while EVT_KEY_RELEASE is not received.
- Send events to you while user is holding the key.
Like he holds 3 seconds the select key: It will send many calls to that function which is within EVT_KEY_PRESS. In the current state it doesn't matter how many time the user holds it will call once the function.
That problem is happening on the device because it is working on the emulator.
The point is that when I hold the select key a power bar will start filling so I need to use a Key Event which allows me to send multiple calls to that function which increases power bar while holding, then when the user releases it gets the power status, but release is working perfectly, the problem is while holding the select key the function is called just once like If I was only pressing the select key once, but I was holding it, so It was supposed to call the function many time as I hold it.
I was using EVT_KEY but I doesn't work holding a key. So I've searched on forums and I noticed that people were using EVT_KEY_PRESS for holding issues, so I changed the EVT_KEY to EVT_KEY_PRESS, but the same thing happens.
Any fix ?

archi wrote:allows you to send events? or sends events to you while user is holding the key?
EVT_KEY_PRESS is called only once - when the user pushes the button.
EVT_KEY is sent with a certain rate repeatedly while user is holding. Or you may want to handle both EVT_KEY_PRESS and EVT_KEY_RELEASE and set a timer on a EVT_KEY_PRESS to call your function while EVT_KEY_RELEASE is not received.
- Send events to you while user is holding the key.
Like he holds 3 seconds the select key: It will send many calls to that function which is within EVT_KEY_PRESS. In the current state it doesn't matter how many time the user holds it will call once the function.
That problem is happening on the device because it is working on the emulator.
The point is that when I hold the select key a power bar will start filling so I need to use a Key Event which allows me to send multiple calls to that function which increases power bar while holding, then when the user releases it gets the power status, but release is working perfectly, the problem is while holding the select key the function is called just once like If I was only pressing the select key once, but I was holding it, so It was supposed to call the function many time as I hold it.
I was using EVT_KEY but I doesn't work holding a key. So I've searched on forums and I noticed that people were using EVT_KEY_PRESS for holding issues, so I changed the EVT_KEY to EVT_KEY_PRESS, but the same thing happens.
Any fix ?

You won't see repeated EVT_KEY_PRESS events sent to your application. The only reason it happens on the Emulator is that Windows translates a key being held down into multiple key strikes. You're better off tracking when you receive the EVT_KEY_PRESS and the EVT_KEY_RELEASE events, and then setting up some sort of timer where for ever x miliseconds the key is held you fill up one part of your power bar.

You won't see repeated EVT_KEY_PRESS events sent to your application. The only reason it happens on the Emulator is that Windows translates a key being held down into multiple key strikes. You're better off tracking when you receive the EVT_KEY_PRESS and the EVT_KEY_RELEASE events, and then setting up some sort of timer where for ever x miliseconds the key is held you fill up one part of your power bar.

mohlendo wrote:You won't see repeated EVT_KEY_PRESS events sent to your application. The only reason it happens on the Emulator is that Windows translates a key being held down into multiple key strikes. You're better off tracking when you receive the EVT_KEY_PRESS and the EVT_KEY_RELEASE events, and then setting up some sort of timer where for ever x miliseconds the key is held you fill up one part of your power bar.
Thx mohlendo, that's what I did.
Now it's working as disered.

mohlendo wrote:You won't see repeated EVT_KEY_PRESS events sent to your application. The only reason it happens on the Emulator is that Windows translates a key being held down into multiple key strikes. You're better off tracking when you receive the EVT_KEY_PRESS and the EVT_KEY_RELEASE events, and then setting up some sort of timer where for ever x miliseconds the key is held you fill up one part of your power bar.
Thx mohlendo, that's what I did.
Now it's working as disered.