FlavorScape FlavorScape - 1 year ago 99
Javascript Question

any way to detect ctrl + click in javascript for osx browsers? no jQuery

using vanilla js. Any way to grab the "right-click" (option-click) from OSX?

function clickey(e)
if(event.button==2 || /*how you'd do it in Java=)*/ e.getButton() == MouseButton.BUTTON3 )

but in js, how do eeet?

Answer Source

You need to listen to the contextmenu event. This is triggered when the context menu should be shown. So either if the right mouse butten or or ctrl + mouse.

If it is not supported then you can try to check the mousedown event where button is 2 and ctrlKey is true if it is triggered by using ctrl + mouse



OR (depending on what the browser supports)

    if( event.ctrlKey || event.button == 2 ) {

edit: removed the which info

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download