Excel-Style Keyboard Shortcuts
in Interactive Grid
Add Alt+A, Alt+D, Alt+S and Alt+R to your editable IG : no plugins, just four clean setup steps using APEX's built-in actions registry.
Prerequisites : Make your IG Editable
row-add-row, row-delete, and save actions only exist in the IG's action registry when the grid is in editable mode. If you skip this, actions.lookup() will return null and throw an error.
In your Interactive Grid region's attributes, set Edit → Enabled to Yes. Read-only IGs won't have row-add or row-delete actions registered : the shortcuts will silently fail.
Give Your IG a Static ID
In Page Designer, click your Interactive Grid region. In the Property Editor go to Advanced → Static ID and enter a unique identifier.
emp_gridSet Cursor Focus to IG on Page Load
Without this, users must click inside the grid first before shortcuts respond. Setting cursor focus means the IG captures keyboard input right on load : just like Excel opens ready to type.
Click the Page node (the root of the page, not a region) in the Rendering tree, then in the Property Editor:
First item on pageAdd JavaScript Initialization Code
This is the core step. Click your Interactive Grid region → go to the Attributes tab → scroll to the Advanced section → find JavaScript Initialization Code. Paste the code below:
actions.lookup("action-name").shortcut = "Alt+X" followed by actions.update("action-name"). The update call is mandatory : without it, APEX doesn't register the shortcut change.
function( options ) { options.defaultGridViewOptions = { skipReadonlyCells: true }; options.initActions = function( actions ) { function setShortcut( names, shortcut ) { var names = Array.isArray(names) ? names : [names]; for (var i = 0; i < names.length; i++) { var act = actions.lookup( names[i] ); if ( act ) { act.shortcut = shortcut; actions.update( names[i] ); break; } } } setShortcut( ["row-add-row", "selection-add-row"], "Alt+A" ); setShortcut( ["row-delete", "selection-delete"], "Alt+D" ); setShortcut( ["save"], "Alt+S" ); setShortcut( ["refresh"], "Alt+R" ); }; return options; }
Here's a quick reference of all shortcuts registered by the code above:
| Shortcut | Action | APEX Action Name | Excel Equivalent |
|---|---|---|---|
| Alt + A | Add a new row | row-add-row |
Insert row |
| Alt + D | Delete selected row | row-delete |
Delete row |
| Alt + S | Save changes | save |
Ctrl+S |
| Alt + R | Refresh the grid | refresh |
F5 / Refresh |
| Alt + Shift + F1 | View all keyboard shortcuts | Built-in APEX shortcut | : |
Testing Your Shortcuts
Run your page and click inside the Interactive Grid. Use the built-in APEX shortcut viewer to confirm your custom shortcuts are registered correctly.
Alt + Shift + F1 on the page to see a popup of all active keyboard shortcuts : your custom ones will appear there automatically alongside APEX's built-in shortcuts.
Alt+Shift+F1 on the running pageactions.update() is called after setting the shortcutArray.isArray helper which tries multiple names safelyHow it works
row-add-row, row-delete, and save actions are only registered in APEX's actions registry when the IG is editable. Calling actions.lookup() on a read-only grid returns null.setShortcut helper accepts an array of possible action names : useful because APEX uses different names depending on the IG view mode (row vs selection). It tries each name and stops at the first match, preventing crashes.actions.update() is mandatory. Setting act.shortcut alone just mutates the object in memory. Calling actions.update(name) tells APEX to re-register and bind the keyboard event listener : skipping it means the shortcut never fires.skipReadonlyCells: true makes Tab navigation jump over display-only columns, exactly like Excel skips locked cells. This makes data entry feel natural and keyboard-friendly.Step-by-step summary
Make IG Editable
Set Edit → Enabled = Yes. Actions like row-add-row only exist in editable mode.
Set a Static ID
Not strictly required for shortcuts, but essential for external JS references and Dynamic Actions.
Set Cursor Focus
Page → Navigation → Cursor Focus = First item on page. Shortcuts work immediately on load.
Paste JS Init Code
IG Region → Attributes → Advanced → JavaScript Initialization Code. This is the core wiring.
Verify with Alt+Shift+F1
Use APEX's built-in shortcut viewer to confirm all four shortcuts appear correctly.
Quick Checklist
Properties → Advanced → Static ID
First item on page
Alt+Shift+F1 to confirm all four shortcuts are registered
Comments
Post a Comment