Skip to content Skip to sidebar Skip to footer

How To Simulate As If User Pressed Ctrl "plus" Plus Or Minus Using Javascript (jquery)?

Is this possible if I click on an anchor link to simulate as if I have pressed Ctrl+ keys on the keyboard (or equivalent on Mac)? if yes, could you show me how to do this, please?

Solution 1:

If you just want to simulate the behaviour of the CTRL+Mousewheel Zoom function, you can use CSS3-Transitions. A nice jQuery plugin for this is jquery Transit.

Example:

$('a.ctrlplus').click(function() {
  $('body').transition({ scale: ($('body').css('scale')+0.1) });
});

Don't know if it works in all Browsers.

Solution 2:

I'm pretty sure you will need to access this on the browser API level, since not all browsers have this functionality or do it the same way.

Solution 3:

I cannot understand what you are going to achieve, but here is a plugin, which made handling keyboard shortcuts very easier.

Here is an example

shortcut.add("Ctrl+Shift+X",function() {
alert("You have pressed Ctrl+____");
});  

Hope it will help you.

Solution 4:

To simulate the zoom function, you can use CSS property "zoom". For JS, it's like:

functionsimulateCtrlKeyPlus() {
   let currentZoom = parseFloat(document.body.style.zoom) || 1document.body.style.zoom = currentZoom * 1.1
}

Post a Comment for "How To Simulate As If User Pressed Ctrl "plus" Plus Or Minus Using Javascript (jquery)?"