Ctrl+click is not working in bxslider

Links are not working as expected in bxSlider.

All links should open in a new tab when you use Command+click (Mac) or Ctrl+click (Windows). I am using bxSlider, and I noticed that right-clicking and selecting "Open in new tab" works fine, but when I use Command+click or Ctrl+click to open a link in a new tab, it is not working; instead, it opens in the same tab.

Many users have already reported this issue on Mac: https://github.com/stevenwanderski/bxslider-4/issues/1188, but none of the methods are working for me. If I use their suggestions, either it doesn't work or it works but the swipe option stops working. After extensive research, I fixed it with a simple method, so I want to share this method with you.

✅ Solution:

We only want to open a link when using the keyboard, so in JavaScript, we can detect key presses. In this scenario, we need to detect Ctrl+click or Command+click. JavaScript has the e.ctrlKey and e.metaKey properties, which return either true or false inside event handlers.

event.ctrlKey for Ctrl+click 
event.metaKey for Command+click

You need to replace this code inside the onTouchStart function in the jquery.bxslider.js and jquery.bxslider.min.js files.

Before:

if (e.type !== 'touchstart' && e.button !== 0) {
	return;
}

After:

if ((e.type !== 'touchstart' && e.button !== 0) || (e.ctrlKey || e.metaKey)) {
	return;
}

This will fix your problem.


Thank You!