I am very confuse and not sure either javascript or jquery can trigger keyboard event like Shift+Q or Alt+Q from button click. I already looking on this forum and also download some of js file like key-event.js and crossBrowser_initKeyboardEvent.js but I still cannot get a result what I want.
My situation is I need to trigger ALT+q key from button html. This should be automatically proceed and will be effect not only inside html(browser) but also on desktop client.
Thanks you.
The effects of keyboard and mouse events fired by Javascript within a web pages are limited to the contents of those web pages. These events cannot reach outside of the web page to trigger keyboard shortcuts in the browser or desktop.
Related
It sound like a simple debug question but I cannot find the solution.
On a web browser like chrome, in the dev panel, I would like to inspect an element (like a button) and then ask chrome to find the corresponding javascript events on the page / file (in order to place breakpoint or to look at the code).
How can I do that ? (without fireing the event and checking the timeline as proposed by #dev3078 in this post How do I monitor what Javascript is being triggered when I click an element in a webpage?). I'd like to have, as in IDE, a 'goto javascript events declaration' !
go to sources, on the right side you'll see a dropdown called Event Listener Breakpoints, expand Mouse Events and select click, when you click on your Dom button, dev tools will go into debugging mode inside the first function called after the click event, you can also choose more events other than click
I want to focus on my browser's previous tabs, so i want to trigger browser tab by triggering key-code. How to do this thing using key code.(and i don't find any keycode for "ctrl+pageup")
That ain't possible.
You can't trigger OS/Browser functions like keypresses from JavaScript.
If this were possible, imagine the problems it would cause by:
sites making you save stuff. (Ctrl+S -> Enter)
sites making you close things. (Alt+F4)
sites making you open new tabs. (Ctrl+T)
etc.
You can only simulate these keypresses within the page's JS.
My friend made it so that on their page you can't right click on the pictures to save them. After inspecting the html it looks like this is done with JavaScript to bind the mousedown event. If I disable JavaScript, then I can right click and save the pictures, but I want to try to see if I can do it without disabling JavaScript. I tried using the JavaScript console to set different values and functions to null, but it didn't work.
I set a breakpoint on the mousedown event and whenever I right click on a picture this is what happens.
return document.addEventListener("mousedown", (function(e) {
return _this.onMouseDown(e);
}), true);
Why is it necessary to bind the mousedown event every time a user clicks the button? Shouldn't it only have to be bound once at the beginning?
I tried using removeEventListener but it didn't do anything. How can I re-enable right click on the pictures?
This is the page.
Just run a browser that has a preference that prevents the web page from blocking right-click and set that preference (such as Firefox or Chrome). I can right-click save any of your friend's images in my default configuration of Firefox.
FYI, there are much more effective ways of doing right-click blocking than your friend is using (including ways that work even when Javascript is disabled), but no scheme can block anyone from taking the images. The images can always be copied via screen capture, grabbing from the browser cache, grabbing the image URL from the page source, etc...
A popular photo service uses a right-click deterrent by putting a scaled transparent gif image over a background image that is the actual image you see. When the user right-clicks they get the transparent gif, not the background image they're looking at. I call it a small deterrent because it's still easily bypassed by any determined thief. This scheme works even when javascript is disabled and even works in browsers like Firefox that prevent apps from blocking right-click because it doesn't use any javascript and because it feeds right-click the blank gif, not the image of interest.
You can see whether there are any other events attached to the document. UseVisual event
Also addEventListener is old way of attaching events, if you could use jquery then you can easily bind/unbind events using bind() and unbind() methods.
I'm writing a chrome history extension, and I was wondering if there's a way to detect when the user clicks a link.
Instead of injecting listeners to every single link via Content-Script, can you utilize: chrome.tabs.onUpdated event? There are many events as well.
But since you stated history, you can use the onVisited event, which fires when a URL is visited.
It would be better to utilize the extension framework instead of relying on content scripts all the time which might become messy.
I want to implement keyboard shortcuts using jQuery.
Specifically, I want to fire an event when e.g. F5 is clicked.
What kind of issues do you run into with keyboard shortcuts?
Also, any online chart that has all the keyboard mappings to numbers?
You can't and shouldn't use F5 key - it's reserved by most browsers as refresh, and even you could you shouldn't want to confuse users by breaking UI conventions
You can use this little app to find out key codes
This little JS library will let you do it:
http://www.openjs.com/scripts/events/keyboard_shortcuts/
however there are some things to note.
1.) In IE, you can't AFAIK stop the event, you are just hooking in before it refreshes
2.) In IE, certain keyboard events you simply can't intercept... e.g. CTRL+S will always bring up the Save dialog, like it or not.