A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Thank you for reaching out and for sharing your concern.
To trigger features when Ctrl+Shift+[ and Ctrl+Shift+{ are pressed, I would recommend using a JavaScript listener inside your add-in's task pane. An Office add-in is essentially a web page that Excel loads, and it does not include any keyboard shortcut by default, so this listener is what gives it the ability to respond to a key combination. The listener and the functions you want to run both live inside the same add-in page, so when the listener detects the keys it simply calls your function directly.
Here is a basic example you can use:
document.addEventListener("keydown", function (event) {
// Ctrl + Shift + [ (the "{" character is produced by Shift + [)
if (event.ctrlKey && event.shiftKey && event.key === "{") {
event.preventDefault();
runFeatureOne();
}
});
function runFeatureOne() {
// Your functionality goes here
console.log("Feature triggered");
}
To quickly test this code in your browser console, please follow these steps:
- Open your add-in in the browser so the task pane is visible.
- Right click anywhere inside the task pane and select Inspect to open the browser developer tools.
- In the developer tools window, select the Console tab.
- Paste the code above into the console and press Enter to register the listener.
- Click inside the task pane, then press Ctrl+Shift+[ to confirm the function runs. You should see the "Feature triggered" message appear in the console.
Please note that code entered directly in the console is temporary and only lasts for the current session. Once you have confirmed it works, you would move the same code into the JavaScript file loaded by your task pane so it runs automatically each time the add-in opens.
One point worth noting is that Ctrl+Shift+[ and Ctrl+Shift+{ are produced by the same physical key, since the { character is simply Shift plus the [ key. Because of this, the two cannot be reliably distinguished as separate shortcuts, so if you need two different features triggered, I would suggest using two distinct keys instead.
Another important limitation is focus. This listener only works while the user is clicked inside the task pane. As soon as focus moves to the spreadsheet cells, the page no longer receives the keystrokes, so the listener will not fire.
I hope this information is helpful. Please follow the steps above and let me know if it works for you. If not, we can continue working together to resolve the issue.
Thank you for your patience and understanding. If you have any questions or need additional assistance, please don’t hesitate to reach out so I can continue to support you. If you found the response useful, please consider marking it as accepted, as this may help other community members who are looking for similar guidance.
I look forward to continuing the conversation.
If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.