0

Hey i need a little advice

window.addEventListener( 'keyup', function ( event ) {

    if ( document.activeElement && document.activeElement.tagName === 'INPUT' ) {

        return;

    }

    switch ( String.fromCharCode( event.keyCode ) ) {

        case 'E':

            window.aimbotEnabled = ! window.aimbotEnabled;

            break

    }

I want to replace the Key "E" with "rightmouseclick" but idk how the case is so i hope you can help me :). So it should trigger when i press my right mouse button instead the key "E"

khelwood
  • 55,782
  • 14
  • 81
  • 108
Socsz
  • 19
  • 2
  • I have retagged your question. Java and JavaScript are unrelated languages. – khelwood Aug 10 '22 at 16:24
  • Does this answer your question? [How can I capture the right-click event in JavaScript?](https://stackoverflow.com/questions/4235426/how-can-i-capture-the-right-click-event-in-javascript) – Raymond Chen Aug 10 '22 at 16:30

2 Answers2

1

You can use "window.oncontextmenu" to capture right click and return false to stop default menu

    window.oncontextmenu = function ()
        {
            
            
             window.aimbotEnabled = ! window.aimbotEnabled;
            return false; 
        
                   
        }
Shozab javeed
  • 232
  • 2
  • 11
  • isnt there a way with just editing the case in my code so a event wich triggers the mouse yk? – Socsz Aug 10 '22 at 16:34
0
window.addEventListener('click', (event) => {
  console.log(event.button)
    if ( event.button === 2 ) {
        window.aimbotEnabled = ! window.aimbotEnabled
        return;

    }

})

Fixed my problem :)

Socsz
  • 19
  • 2