> ## Content Index
> Fetch the complete content index at: https://henleyedition.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Code Snippet: Re-enable Ctrl/Cmd-click when using e.preventDefault()
- URL: https://henleyedition.com/allow-ctrl-command-click-using-event-preventdefault/
- Published: 2014-08-05T23:34:40.000Z
- Updated: 2014-12-16T04:06:25.000Z
- Author: Evan Henley
- Tags: programming, #Import 2026-11-15 06:05

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.

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

```