function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Create a Visualfroce keyboard shortcut?

I've got a method in my class that updates records. Some of my more savvy users would like a CTRL+S function to activate this while they're just sitting there.


Is there anyway to implement this? I don't see anything in the documentation.


The attribute you're looking for is "accesskey". That will let you assign a hot key (as per HTML standards). You can also use normal JavaScript; assign a body onKeyPress event handler that watches for a given keypress (e.g. Ctrl-S), and once detected, it can call an actionFunction defined in the form (or you can query for the commandButton by ID, and activate its onclick handler). I'd take a look at a normal course in JavaScript for help on that.


I tried something like this on my form and it won't work. Thanks for the Access key tip, though. I think users can adjust to using alt+s vs. ctrl + s. I'd still like to get ctrl + s working. 

<apex:actionFunction name="saveThePage" action="{!updateRecords}"/>
        window.onKeyPress = whatKey();
        function whatKey(e){
            //if ctrl is pressed
                //if 'S' key is pressed
                if(e.keyCode == 83){
                if(e.keyCode == 115){