Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard Shortcuts in my JSF page

Tags:

java

jsf

jsf-2

I was wondering if there is a way to make an easy keyboard shortcut in my JSF page

each page has several buttons and I would like to be able to have a user press something like alt+a to activate a button called 'Add Report to Group'

in .net you just put an & before the letter you want to be the shortcut key, is there an option like this in JSF (apart from writing some javascript code which is what I found on the web)

like image 480
ScottC Avatar asked Feb 24 '23 22:02

ScottC


1 Answers

Use the HTML-provided accesskey attribute which is also mapped in <h:commandButton> and <h:commandLink>.

<h:commandButton value="Add" accesskey="a" action="#{bean.add}" />

This button can then be invoked by Alt+A or Shift+Alt+A, depending on the browser used.

like image 159
BalusC Avatar answered Mar 04 '23 13:03

BalusC