Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a keyboard shortcut in Google Chrome which will break script execution? (Equivalent to pressing the || "Pause script execution" button in the Developer Tools Scripts panel.)

I'd like to use the Dev Tools to inspect an element in its mouseover state; the mouseleave code will obviously run if I try to actually click the pause button!

share|improve this question

3 Answers 3

up vote 13 down vote accepted

While I haven't found the exact solution to this problem, I did come up with a one-liner that can be put in a page to achieve my goal:

$(window).keydown(function(e) { if (e.keyCode == 123) debugger; });

This will cause execution to be paused when you hit F12.

(debugger is a JavaScript statement that forces a breakpoint.)


Update: Dev Tools has many built-in shortcuts (press F1 for a list), but you must be focused in the Dev Tools window for them to work. Pausing script execution is F8 or Ctrl+/.

The above one-liner might still be useful if you need to stay focused in the page before pausing.

share|improve this answer
    
+1 Very useful! Thanks. –  Andrew Mao Jan 30 at 0:49

Exercising my Google-fu, I found the official google list of Chrome keyboard shortcuts

It doesn't seem like there's one dedicated to it. You could always write a plugin which would interpret a key combination as a pause button, though, if you wished.

share|improve this answer

I wrote a quick little Chrome Extension that allows you to press the Pause button on your keyboard to pause javascript execution

Source

Package

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.