VS Code Shortcuts

Helper functions for coding on VS Code in the browser (vscode.dev)

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         VS Code Shortcuts
// @namespace    http://tampermonkey.com
// @version      1
// @description  Helper functions for coding on VS Code in the browser (vscode.dev)
// @match        https://*.vscode.dev/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Add a shortcut to open the command palette
    document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.shiftKey && event.key === 'P') {
            document.querySelector('.command-palette').click();
        }
    });

    // Add a shortcut to toggle the sidebar
    document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.key === 'B') {
            document.querySelector('.activitybar .toggle-more').click();
        }
    });

    // Add a shortcut to toggle the terminal
    document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.key === '`') {
            document.querySelector('.panel-switcher .terminal').click();
        }
    });

    // Add a shortcut to toggle the output panel
    document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.altKey && event.key === 'O') {
            document.querySelector('.panel-switcher .output').click();
        }
    });

    // Add a shortcut to toggle the problems panel
    document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.altKey && event.key === 'P') {
            document.querySelector('.panel-switcher .problems').click();
        }
    });

    // Add a shortcut to toggle the search panel
    document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.shiftKey && event.key === 'F') {
            document.querySelector('.panel-switcher .search').click();
        }
    });

})();