Catching key strokes using Dynamic Actions in Oracle APEX 4.x
One of the demands for a customer application built in Oracle Application Express was, that a part of the application could be completely operated by the numpad of a keyboard. This had to do with the physical aspects of one of the workstations. There was simply not enough room for a full keyboard.
When building an APEX application, you have several tools to your disposal to allow this. First of all there is the option “Submit when ENTER pressed” on text items that removes the need for buttons to submit a page.
Next there are some built in possibilities in Dynamic Actions. For example; there is the True Action setFocus that allows a developer to automatically put the focus on a certain item (for example the item that submits when ENTER pressed) in case of an event (like Page Load). With these two you can already build a simple page to navigate through the pages of your application.
One more demand was for a certain page to scroll back and forth using the plus(+) and minus(-) keys on the numpad. This also is relatively easy to do in APEX. It requires a Dynamic Action and one line of JavaScript.
Here are the steps to take when catching the plus(+) key stroke.
- First create a new Dynamic Action
- The event should be ‘Key Release’
- As Item select one of the items on your page
- Add a condition of type “JavaScript expression”
- The value of this condition is “this.browserEvent.which === 107” (107 is the plus(+) key, 109 is the minus(-) key)
- Add an action to perform on this event, like an alert.
And that’s it!
The result should look like the following screenshot:
Key Release Dynamic Action
Overzicht blogs
Geen reacties
Geef jouw mening
Reactie plaatsenReactie toevoegen