Skip to content

Instantly share code, notes, and snippets.

@ronnyandre
Last active December 15, 2015 12:39
Show Gist options
  • Save ronnyandre/5261967 to your computer and use it in GitHub Desktop.
Save ronnyandre/5261967 to your computer and use it in GitHub Desktop.
Don't prevent events when users hold CTRL or META keys
document.getElementById("myLink").addEventListener("click", function(e) {
// e.preventDefault(); (bad)
if(e.meta || e.ctrlKey) return; // Don't block user if they want to open a new tab
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment