VS Code Shortcuts

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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();
        }
    });

})();