web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Creating custom keyboard shortcuts in Dynamic 365

(0) ShareShare
ReportReport
Posted on by 25

I'm in a company that is upgrading from Crm2011 to Dynamics 365. Our current solution rely heavily on using shortcuts, which is a very important requirement from our users.

We are experiencing problems with adding shortcuts in Dynamics 365 using the Mousetrap-api (https://craig.is/killing/mice) and have tried other api's as well without succes

The shortcuts are added onformload like this, and we are seing the messages "Adding shortcuts" and "Adding shortcuts - done" in the console, but none of the shortcut seems to work

function OnCrmFormLoad(ctx) {
        console.log("Adding shortcuts"); 
        Mousetrap.Add('5', function() {console.log('5'); }); 
        Mousetrap.Add('ctrl k', function() {console.log('ctrl k'); }); 
        console.log("Adding shortcuts - done"); 
}

Are custom keyboard shortcuts not supported in Dynamic 365? or is there another way to add custom keyboard shortcuts?

I have the same question (0)
  • Pankaj Gogoi Profile Picture
    3,177 on at
    RE: Creating custom keyboard shortcuts in Dynamic 365

    Hi,

    Here are the list of shortcuts for D365.

    https://docs.microsoft.com/en-us/powerapps/user/keyboard-shortcuts

    https://docs.microsoft.com/en-us/dynamics365/business-central/keyboard-shortcuts#keyboard-shortcuts-in-cards-and-documents

    Hope this helps

    Best Regards

    PG

  • Larsyde Profile Picture
    25 on at
    RE: Creating custom keyboard shortcuts in Dynamic 365

    Thanks - but this is not what I asked for. We are well aware of the standard keyboard shortcuts in D365, but they don't cover our needs

  • Pankaj Gogoi Profile Picture
    3,177 on at
    RE: Creating custom keyboard shortcuts in Dynamic 365

    Which browser you are using? Is it logging any exception to the browser window. Can you debug the Mousetrap.Add function and see if there are any inner exception.

    Good Luck

    Best Regards

    PG

  • Larsyde Profile Picture
    25 on at
    RE: Creating custom keyboard shortcuts in Dynamic 365

    Thanks for your reply. I'm using Chrome, but have tried Edge as well - same result with both browsers.

    I was able to debug Mousetrap.Add (which is actually called Mousetrap.bind - typo :-)). I was able to step all the way through without any inner exceptions. Seems like D365 is "eating" all mousetrap-events - if I replicate the same code in a simple html-page everything works fine

  • Verified answer
    Larsyde Profile Picture
    25 on at
    RE: Creating custom keyboard shortcuts in Dynamic 365

    So we finally managed to find a solution.

    It appeared that the problem was that clientscript is embedded in an iframe in D365, so the eventlisteners was added to this frame instead of the actual D365 form. By setting the target of the event to the parent of the iframe we managed to solve the problem

  • Cinematic Profile Picture
    5 on at
    RE: Creating custom keyboard shortcuts in Dynamic 365

    I think Microsoft Edge will help you for this. Or visit 10kbeasts for keyboards related queries 

  • CU13110901-0 Profile Picture
    2 on at
    Creating custom keyboard shortcuts in Dynamic 365
    Creating custom keyboard shortcuts in Dynamics 365 can be challenging, especially when transitioning from older versions like CRM 2011 where client-side scripting had more flexibility. Dynamics 365 has stricter security and sandboxing for form scripts, which can interfere with external libraries such as Mousetrap. When shortcuts fail to trigger despite initialization messages appearing, it’s often due to event handling being blocked or overridden by the platform’s internal scripts. To make shortcuts work reliably, consider attaching them after the form is fully loaded using the formContext.data.entity.addOnSave or formContext.ui events, or by injecting them dynamically once the DOM is ready rather than on form load. Another approach is to leverage modern Power Apps Component Framework (PCF) controls, which allow more controlled interaction with the DOM and can safely implement keyboard shortcuts without violating Dynamics 365’s security model. desicinema

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 101

#2
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans