Code Snippet: Re-enable Ctrl/Cmd-click when using e.preventDefault()

In Windows and OSX, pressing control or command while clicking a link opens it in a new tab. Using event.preventDefault() on anchor tags breaks this native behavior, but you can use this code to restore it.

// allow command-click and control-click to open new tab
if (event.metaKey || event.ctrlKey) {  
    return;
} else {
    event.preventDefault();
}