As I understand it right we are supposed to not use href="/..." attributes anymore in Lightning and have onclick="{c.navigateToSObject}" instead.

navigateToSObject: function(cmp, event, helper) {
        var evt = $A.get("e.force:navigateToSObject");
            "recordId": recordId,
            "slideDevName": "detail"

But how do I get Command-Click (on Mac) to work with that?

According to this https://success.salesforce.com/ideaView?id=08730000000CIt7AAG it seems to be possible and is perfectly working for all links generated by the Salesforce UI. Just CMD-click any lookup field on a record page.


1 Answer 1


Here is example how to detect if CTRL key is pressed: Any way to detect keyup and keydown events NOT using an input field?

You can also use Salesforce url like here: Open link in another tab with e.force:navigateToURL

I did not try on mac, but on windows this works for me:

if(event.ctrlKey) {
} else {

If you want to navigate to sObject, use url like this:


If you want to navigate to custom component, you can do some trick to get url. In your url one/one.app#eyJjb... symbols after # is base64 json that decoded looks like this:

    "a:t": 1496392690947, // time when opened
    "attributes": {
        "values": {
            // your component attributes
    "componentDef": "c:YourComponent"

So you can try to generate your json data, base64 encode and redirect to it.

To see your url decoded and parsed in lightning app, try this:

  • As I understand the solutions they don't provide the option to open a link in a new tab but enforce it all the time. What I need is a way to open it in a tab when the user does a CMD-Click. Jun 2, 2017 at 10:49
  • How would I have to convert my <a onclick="{!c.handler}"> to make that work? Jun 2, 2017 at 11:08
  • Does it work if you put code that redirects in handler method in controller? Jun 2, 2017 at 11:20
  • Sure. I can do that. Jun 2, 2017 at 11:22
  • So what is still the problem? Jun 2, 2017 at 11:26

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.