Thursday 7 February 2013

Enabling the Keyboard Hot Keys(Ctrl+ Any Key) in an Application


Hot Keys are used in most of the application for reduce the no. of navigation and short-cut activity to end user. Hot keys are very common and used all our day today applications. We will achieve same in ADF by using the following steps.

Need to register the Hot Keys on the Page Load by using the Java script.In this first, need to find the Key Stroke code by using the API of AdfKeyStroke.getKeyStrokeFromMarshalledString() and second need to register Key Stroke code by using the API of AdfRichUIPeer.registerKeyStroke().



RegisterKeyStroke contains the method of 'callBack()' and it will call whenever register key is pressed from the Key Board. From callBack method has a logic to trigger the respective button actions.  


For more details check with sample.

[Runs with Oracle JDeveloper 11g R2 Update3]

How to run this sample?
Run using the HotKeys.jsf and check the behaviors of Hot Key Actions. If you pressed ctrl+S then it triggers Save Action and ctrl+R then it triggers Reset Action.

1 comment:

  1. Nice Post.
    _hotKeys[0] ="ctrl S";//For Ctrl+S keys.
    I want to set for CTRL+ArrowDown how to initialize that?
    I tried _hotKeys[0] ="ctrl ArrowDown";
    But it is not working

    ReplyDelete