<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Event mapping for function keys</title><link>https://answers.axonivy.com/questions/397/event-mapping-for-function-keys</link><description>&lt;p&gt;I search for a possibility to start a rich dialog event with the function keys on the keyboard, e.g. to use F5 for refresh. I was successful to use the normal keys for characters or digits, but not for the function keys. How could this be possible?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/397/event-mapping-for-function-keys" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 31 Mar 2011 07:32:59 -0400</lastBuildDate><item><title>Answer by Andras Fejer</title><link>https://answers.axonivy.com/questions/397/event-mapping-for-function-keys/398</link><description>&lt;p&gt;I did have the same problem and solved it like this: &lt;/p&gt;
&lt;p&gt;I added buttons to the Rich Dialog panel for which I wanted to call events from function keys. For the buttons I added a normal event that handles the normal click of the button. Furthermore I added a &lt;code&gt;ActionListener&lt;/code&gt; in the &lt;code&gt;initialize()&lt;/code&gt; method of the panel that reacts on function keys and then invoke the click of the button programmatically.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;private void initialize(){
    ...

    KeyStroke refresh = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0);
    this.registerKeyboardAction(new IActionListener(){
        public void actionPerformed(ActionEvent event){
            if(RefreshButton.isEnabled() &amp;amp;&amp;amp; RefreshButton.isVisible()){
                RefreshButton.doClick();
            }
        }
    }, refresh, ULCRootPane.WHEN_IN_FOCUSED_WINDOW);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the &lt;code&gt;ActionListener&lt;/code&gt; we register a &lt;code&gt;KeyStroke&lt;/code&gt; object for a key (in this case F5) as an action. The &lt;code&gt;actionPerformed()&lt;/code&gt; method is then invoked when the user presses F5. &lt;/p&gt;
&lt;p&gt;Instead of a button you can too use a hyper link and you even can make it invisible. If you do so, then do not forget to adapt the &lt;code&gt;if&lt;/code&gt; part in my code.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Andras Fejer</dc:creator><pubDate>Thu, 31 Mar 2011 07:32:59 -0400</pubDate><guid>https://answers.axonivy.com/questions/397/event-mapping-for-function-keys/398</guid></item></channel></rss>