ショートカットキー
code:script.js
import loadScript from '/api/code/src-wintyo/library/loadScript.js';
(async () => {
await loadScript('platform.min.js', url);
const os = platform.os.toString();
const isWindows = /windows/i.test(os);
document.addEventListener('keydown', (event) => {
// WindowsとMacによってコントロールキーを変える
const isActionKey = isWindows ? event.altKey : event.ctrlKey;
// hrアイコンを入れる
if (event.key === 's' && isActionKey) {
document.execCommand('insertText', null, '/icons/hr.icon\n');
}
// 新規作成画面を開く
if (event.key === 'c' && isActionKey) {
const match = location.href.match(/https:\/\/scrapbox.io\/(a-zA-Z0-9_-+)\//); if (!match) {
alert('cannot get Project Name!');
return;
}
const projectName = match1; location.href = https://scrapbox.io/${projectName}/new;
}
});
})();