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?
something like
<a href="#" onclick="simulateCtrlKeyPlus();return false;">Ctrl+</a>
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?
something like
<a href="#" onclick="simulateCtrlKeyPlus();return false;">Ctrl+</a>
Share
Improve this question
edited Jun 12, 2012 at 12:16
user1421214
asked Jun 12, 2012 at 11:18
user1421214user1421214
9094 gold badges17 silver badges25 bronze badges
0
4 Answers
Reset to default 3If 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.
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.
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.
To simulate the zoom function, you can use CSS property "zoom". For JS, it's like:
function simulateCtrlKeyPlus() {
let currentZoom = parseFloat(document.body.style.zoom) || 1
document.body.style.zoom = currentZoom * 1.1
}