key applications
- liulanger521
- Posts: 10
- Joined: Fri Oct 08, 2010 7:31 pm
key applications
When I press the key, I want to set some parameter as “1”, when I leave the key, I want to set some parameter as “0”.
How could I achieve it?
How could I achieve it?
- jpurdum
- Enovation Controls Development
- Posts: 153
- Joined: Mon Jun 21, 2010 11:19 am
Re: key applications
Please find the attached .db3 config file that demonstrates what I believe you've asked for.
When you look at the config on the Page Designer screen, keep in mind, to see the key up mapping, you must switch from Key Press to Key Up mode.
You will see the event I tied to the upper right button changes from the KeyPressed event to the KeyReleased event.
KeyPressed and KeyReleased are both calculations on the database variable DemoKeyValue. KeyPressed just sets DemoKeyValue to 1 and KeyReleased sets it back to 0.
Here's the demo configuration.
When you look at the config on the Page Designer screen, keep in mind, to see the key up mapping, you must switch from Key Press to Key Up mode.
You will see the event I tied to the upper right button changes from the KeyPressed event to the KeyReleased event.
KeyPressed and KeyReleased are both calculations on the database variable DemoKeyValue. KeyPressed just sets DemoKeyValue to 1 and KeyReleased sets it back to 0.
Here's the demo configuration.
- mbowdich
- Posts: 209
- Joined: Tue Oct 05, 2010 10:54 am
Re: key applications
Be very cautious with using a key down / key up combination. While holding the key down, if any other key is pressed and held in the row or column of that key, the key up will not trigger and it will be caught in the key down position. This is especially dangerous if another is pressed that takes you to a different page that the key up does not exist on. Pressing the original button (on the same page that the key down / key up is on) will effectively reset it.
This happens because of the matrix design of the button interface.
If it is a critical application that would have adverse effects of being caught in the key down position, you could consider using an external button connected to one of the 3 inputs on the display. With a simple state machine, you can acomplish what you described.
This happens because of the matrix design of the button interface.
If it is a critical application that would have adverse effects of being caught in the key down position, you could consider using an external button connected to one of the 3 inputs on the display. With a simple state machine, you can acomplish what you described.
- liulanger521
- Posts: 10
- Joined: Fri Oct 08, 2010 7:31 pm
Re: key applications
To all
Thanks very much
Thanks very much
- JZanni
- Posts: 29
- Joined: Tue Oct 12, 2010 3:09 pm
Re: key applications
mbowditch wrote:
My understanding is that Key up and Key Press are technically transition events generated by the change of state of the button. Pressing a button or releasing a button will generate a single event. I can understand that pressing another key while releasing the first key or if the second key changes the page this will effectively mask the key up event of the first key. However I fail to understand the statements "..will be caught in the key down position.." and "..will effectively reset it." unless it refers to the user logic associated with such events being caught or reset because the events are not triggered. Could you elaborate?
While on the subject, can someone explain the Key Hold event? I tried but failed to write some logic where a counter would increment while the key was held down. Part of the issue is that Key Hold unlike Key press and Key Up implicitly describes a state. In standard VB the event is normally "WhileDown" and it is normally associated with a timer which triggers the event if the key is down every (X) ms. I could not find such timer associated with the KeyHold. I assumed that the event timer was built in and the Key Hold would self-repeat. It did not seem to work. How can we use the Key Hold function? An example will be appreciated.
Also in the action for the CCM, a Key Repeat enable/disable event is listed. But such event is not described anywhere else.
I am a bit confuse by some of this statement and by the Key events in general.Be very cautious with using a key down / key up combination. While holding the key down, if any other key is pressed and held in the row or column of that key, the key up will not trigger and it will be caught in the key down position... ... Pressing the original button (on the same page that the key down / key up is on) will effectively reset it.
My understanding is that Key up and Key Press are technically transition events generated by the change of state of the button. Pressing a button or releasing a button will generate a single event. I can understand that pressing another key while releasing the first key or if the second key changes the page this will effectively mask the key up event of the first key. However I fail to understand the statements "..will be caught in the key down position.." and "..will effectively reset it." unless it refers to the user logic associated with such events being caught or reset because the events are not triggered. Could you elaborate?
While on the subject, can someone explain the Key Hold event? I tried but failed to write some logic where a counter would increment while the key was held down. Part of the issue is that Key Hold unlike Key press and Key Up implicitly describes a state. In standard VB the event is normally "WhileDown" and it is normally associated with a timer which triggers the event if the key is down every (X) ms. I could not find such timer associated with the KeyHold. I assumed that the event timer was built in and the Key Hold would self-repeat. It did not seem to work. How can we use the Key Hold function? An example will be appreciated.
Also in the action for the CCM, a Key Repeat enable/disable event is listed. But such event is not described anywhere else.
- mbowdich
- Posts: 209
- Joined: Tue Oct 05, 2010 10:54 am
Re: key applications
You are correct in that the key up will be masked if the page changes or if another button is being pushed. Most uses that I can think of for key down / key up is for ding exactly what you aim to do with key hold.
For example, let's say the key down action triggers a state machine and timer to continually increment a variable and the key up stops the increment. If the key up is masked by the events already described (page cahnge, etc.), the state machine and timer will continue to increment the variable indefinately. The only way to stop it is to get back to the same page that the key down / key up combination exists, then press and relelease the key. This "resets" the state machine back to not incrementing, becausee the key up action is finally initiated.
If I recall, the key hold is not for continuously incrementing, but rather to require the user to continously hold the button for 5 seconds for the action to be triggered.
For example, let's say the key down action triggers a state machine and timer to continually increment a variable and the key up stops the increment. If the key up is masked by the events already described (page cahnge, etc.), the state machine and timer will continue to increment the variable indefinately. The only way to stop it is to get back to the same page that the key down / key up combination exists, then press and relelease the key. This "resets" the state machine back to not incrementing, becausee the key up action is finally initiated.
If I recall, the key hold is not for continuously incrementing, but rather to require the user to continously hold the button for 5 seconds for the action to be triggered.
- drphil69
- Posts: 139
- Joined: Wed Mar 02, 2011 5:59 pm
Re: key applications
Hello,
I have a question for jpurdum on the program attached -
Demo - Key Press and Release.db3
I tried sending a private message and got an error.
In the above mentioned program, there is state machine, EnableKeyUPOnStartUp... What is the purpose of this? Do I need to include something like this in any program where I use Key Up?
Thanks,
Phil
I have a question for jpurdum on the program attached -
Demo - Key Press and Release.db3
I tried sending a private message and got an error.
In the above mentioned program, there is state machine, EnableKeyUPOnStartUp... What is the purpose of this? Do I need to include something like this in any program where I use Key Up?
Thanks,
Phil