Reputation: 9077
When dev tools is focused, you can clear the console with the shortcut cmd + k
. Is there a shortcut or a hack to clear the console while having focus on the web-page itself?
Background: I'm often using the mouse to click some buttons in the webpage and I'd like to clear the console using a shortcut with my left hand just before I click the button with the cursor (the right hand can't since it's holding the mouse)
Upvotes: 2
Views: 550
Reputation: 25917
Here's a hack. This only works on Chrome 61 and later. 61 is currently in Beta. It should hit Stable by mid-September 2017. Check chrome://version
to see what version you're running.
Upvotes: 0
Reputation: 16561
You can add a handler to the page that calls the console.clear
method when a shortcut is used.
document.body.onkeydown = function(){
console.clear()
}
This will clear the console when any key is pressed, but you can easily add an if statement that checks that the key that was pressed matches the shortcut you want to use.
Upvotes: 2