1

I have a lightning component that provides it's own hotkeys and those are now overlapping with the new LEX hotkeys released in Summer '17. So pressing 'e' pops open the LEX edit, when i'd like to do something else. Salesforce also kills all propigation so my listener doesn't even get a chance to react. I'd like to disable the LEX hotkeys or better yet find a way to avoid triggering them when my component isRendered().

This is a long shot - I've already dug through the javascript and am pretty sure it's impossible.

  • Can confirm its impossible from lightening components, you can do this from Chrome extension or Tampermonkey, this is not a salesforce solution though. – Prafulla Patil Jul 11 '17 at 20:05
5

Alright - Suuuuper hacky, but I found a way. There is some code in keyComboProcessor.js _isEditingText() that checks a few ways the user could be editing. If you match these with your focused element you can sneak around the handler.

_isEditingText:function(keyboardEvent) {
    var targetElmt = keyboardEvent.target;
    if(targetElmt.tagName === "INPUT") {
      return!!EDITING_INPUT_TYPES[targetElmt.type]
    }
    if(targetElmt.tagName === "TEXTAREA") {
      return true
    }
    if(targetElmt.tagName === "DIV" && targetElmt.className) {
      return targetElmt.className.indexOf("cke_editable") !== -1 || targetElmt.className.indexOf("ql-editor") !== -1
    }
    if(targetElmt.tagName === "A") {
      return targetElmt.className.indexOf("select") !== -1 || !!(targetElmt.getAttribute("role") && targetElmt.getAttribute("role").indexOf("menuitem") !== -1)
    }
    return false
  }

For me, I just focused a DIV with a tabindex and gave it the cke_editable class.

  • This worked great for me, thanks for finding this. I have a div with contentEditable = true and was having an issue with e and / firing Salesforce shortcuts. Adding cke_editable to the div stopped all Salesforce shortcuts – Benjamin Vogler Jul 10 '19 at 18:47
  • Hi, Where can I find this "keyComboProcessor.js" file to make changes ? – sf_user Apr 8 '20 at 11:09
  • 1
    @sf_user This is a SF system file, you can't modify it. What wellmstein was referring to is that he looked inside the code of that file and he noticed that piece of code that gave him the idea. In other words you don't have to modify the file, what you need to do is add a class name of "cke_editable" to your div and it will bypass the keyboard shortcuts. – Arthlete Jun 12 '20 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.