Hotkey is used to bind a key or a key combination to an client side or server side event via ajax. In first example use "left" and "right" keys to switch images and in second example you can do an ajax request with the (ctrl+shift+s) combination.
<div class="card">
<h:form>
<h5 class="p-mt-top">ImageSwitch Integration (Left-Right)</h5>
<p:imageSwitch effect="fade" widgetVar="switcher" slideshowAuto="false">
<p:graphicImage name="demo/images/nature/nature1.jpg"/>
<p:graphicImage name="demo/images/nature/nature2.jpg"/>
<p:graphicImage name="demo/images/nature/nature3.jpg"/>
<p:graphicImage name="demo/images/nature/nature4.jpg"/>
</p:imageSwitch>
<p:hotkey bind="left" handler="PF('switcher').previous()"/>
<p:hotkey bind="right" handler="PF('switcher').next()"/>
<h5>Ajax Hotkey (ctrl + shift + s)</h5>
<p:growl id="msgs" showDetail="true" skipDetailIfEqualsSummary="true"/>
<p:hotkey bind="ctrl+shift+s" update="msgs" action="#{hotkeyView.save}"/>
<h:panelGrid columns="2" cellpadding="7">
<p:outputLabel for="text" value="Text"/>
<p:inputText id="text" value="#{hotkeyView.text}"/>
</h:panelGrid>
</h:form>
</div>
@Named
@RequestScoped
public class HotkeyView {
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public void save() {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Success", "Submitted with Hotkey"));
}
}