I have coded some stuff:
http://fincha.com/kunden/schmitt/
I zoom in with .css("zoom") but I need the buttons to simulate CTRL + or CTRL -
This code isn't working for me:
e = jQuery.Event("keydown");
e.which = 50;
$("input").trigger(e);
Please help!
EDIT
I just wont to zoomin and zoomout the hole page
jQuery normalizes modifier keys on events by setting one or more properties on the
event
object. So, you want to setevent.ctrlKey
totrue
, so this should work for you:However, as per a comment at source (linked below):
So, if you're unable to set the event's properties after constructing the
Event
object, then you can$.extend()
it to set thectrlKey
property:One other thing: I'm not sure if you're trying to use key code
50
for the + or the - keys. Maybe you are, and you're using a different keyboard layout, but according to this demo,50
is the JavaScript key code for hitting 2 - so that could also be part of your problem.Source: comments on a jQuery API page.
Edit:
All this aside, I don't think you can actually change the browser's zoom level using JavaScript, even if you're "sending" the keyboard command to do so.
Access browser's page zoom controls with javascript
Source: http://www.scottklarr.com/topic/126/how-to-create-ctrl-key-shortcuts-in-javascript/
This is for Ctrl+s, but you should be able to modify it easily.