HardwareKeyEvent

tsdt

Active Member
Licensed User
Hi all,

I am currently trying out the Hardware Key Event. However, I cannot raise the Hardkey_event.

Is there any kind of tricks I can perform to capture all the keys?

Thanks
 

tsdt

Active Member
Licensed User
The event should be raised when you press on one of the 'hard' keys.
Doesn't it work for you?
Can you upload your code?

Sorry, I have rewritten the whole thing using the keyevent of the button, even though, I need to make sure that the focus is on the button on the time. :p And this works.

However, can you please explain further on this 'hard' keys to me?? I tried to read the chm but, I failed to understand what the hardkey mean and how to use it in my application..

:)

:sign0089:
 

mjcoon

Well-Known Member
Licensed User
However, can you please explain further on this 'hard' keys to me?? I tried to read the chm but, I failed to understand what the hardkey mean and how to use it in my application.

I think that the "hard" is to distinguish from the "soft" keys that are displayed on the touch screen and therefore very variable and only visiible when the device is switched on. The hard keys are built into the case, usually on the front or sides.

I think that the difference between soft keys and buttons is that keys represent an alphanumeric keyboard ("SIP") whereas buttons are more general in layout and do not look like a keyboard.

HTH, Mike.
 

tsdt

Active Member
Licensed User
I think that the "hard" is to distinguish from the "soft" keys that are displayed on the touch screen and therefore very variable and only visiible when the device is switched on. The hard keys are built into the case, usually on the front or sides.

I think that the difference between soft keys and buttons is that keys represent an alphanumeric keyboard ("SIP") whereas buttons are more general in layout and do not look like a keyboard.

HTH, Mike.

So, does it mean that the hardkey would be registered under the registry and the softkey would be just the GUI?

But, both should generate the same key event right?? How come I could not get any key event out of hardkey??

Very strange indeed.

:sign0089:
 

mjcoon

Well-Known Member
Licensed User
So, does it mean that the hardkey would be registered under the registry and the softkey would be just the GUI?

But, both should generate the same key event right?? How come I could not get any key event out of hardkey??

Yes, I expect that the default (viz. not intercepted) behaviour of the hard keys would be in the registry somewhere. Actually I would like to know where but have not asked that question yet. Partly because the answer may depend on what type the device is and/or which OS, which would make it a bit complicated. My device has a Settings screen to choose the default or Today Screen action of each hard key for quick and slow presses.

On your second question, no, the process of establishing an event Sub for hard and soft keys is different. For soft keys the event Sub is named depending on the name you have chosen for the key/button. For hard keys they all come via one event Sub which is named after the name of the HardKey object that you have to set up within the Hardware library, as in my HardKey_HardKeyPressed below. Then you have to test for which KeyN (1 <= N <= 5) has been pressed.

(In my Music Player program I wanted to have the hard key #5, which on my device is on the side and can be pressed even when it is in its protective case, to be a "pause"/"play" key, so I use event HardKey_HardKeyPressed and check for HardKey.Key5. But really I would like other keys to have their default purpose which requires reading it from the registry or somewhere.)

HTH, Mike.
 

mjcoon

Well-Known Member
Licensed User
The event should be raised when you press on one of the 'hard' keys.

I should have said when describing how I get the event from hard key #5 that there must be a different system event if the key/button is held down for longer than a second or two. (The built-in Settings list allows different applications to be invoked for a short press and a long press.)

So if I hold the button for too long I do not get the Basic4PPC event in my program and instead get the system setting invocation for a long press.

Ideally the Hardware library would provide another event for a longer press. But it does mean that you may fail to get the event you expect if you press the key for too long.

Mike.
 
Top