I know I can use capture the Right Click event by using jQuery's "contextmenu" but my question is, how can I capture the event after the context menu appears i.e. When the user clicks on "Open Link in New Tab" action.
Any help?
Thanks.
It's not possible, however, you can use a workaround to detect similar behavior. For example, if you're dealing with links ( tags), you can listen for the click event and check if the user is using Ctrl (Windows) or Cmd (Mac) to open the link in a new tab:
document.querySelectorAll('a').forEach(link => {
link.addEventListener('click', (e) => {
if (e.ctrlKey || e.metaKey) {
console.log('Link opened in a new tab');
}
});
});
This method will capture when a user opens a link in a new tab using the keyboard shortcut.
Alternatively, you can create a custom context menu that captures right-click actions and manage the "Open in New Tab" functionality within your app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With