Using the onClick event with CTRL key

Hi, I have a button on my site and I would like it to have some special behaviour if you hold the CTRL key while clicking. Is there a way to do this using JS?

Use the onKeyPress event handler.

I cannot recall on the top of my head if the button has this as an option but if not, place it in a container and use the onKeyPress for the container event. Since it would be the parent element, this would be a suitable workaround.

1 Like