Last active
May 18, 2020 19:34
-
-
Save vitalibondar/6128421c3ad8ca6a8e3029259ebc02d1 to your computer and use it in GitHub Desktop.
Vim-style navigation in Scrapbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code:script.js | |
//うまく動かないのでいったん保留 | |
// import 'https://scrapbox.io/api/code/cdn/キーボードだけでページ遷移/ショートカットキーでページ遷移.js' | |
addEventListener('keydown', e => { | |
if(!$('#text-input').is(":focus") && !$('.search-form input').is(":focus")) { | |
//focus to editor to insert text | |
if(e.key === 'i') { | |
$('#text-input').focus(); | |
e.preventDefault(); | |
} | |
if(e.key === 'ш') { | |
$('#text-input').focus(); | |
e.preventDefault(); | |
} | |
//back to top page | |
if(e.key === 't') { | |
$('.project-home')[0].click(); | |
e.preventDefault(); | |
} | |
if(e.key === 'е') { | |
$('.project-home')[0].click(); | |
e.preventDefault(); | |
} | |
//search notes | |
if(e.key === 's') { | |
$('.search-form input').focus(); | |
e.preventDefault(); | |
} | |
if(e.key === 'и') { | |
$('.search-form input').focus(); | |
e.preventDefault(); | |
} | |
if(e.key === 'ы') { | |
$('.search-form input').focus(); | |
e.preventDefault(); | |
} | |
//go to private project | |
if(e.key === 'p') { | |
// window.location.href = 'https://scrapbox.io/vb/'; | |
$($('.global-menu-for-user').children()[3]).children()[0].click(); | |
e.preventDefault(); | |
} | |
if(e.key === 'з') { | |
// window.location.href = 'https://scrapbox.io/vb/'; | |
$($('.global-menu-for-user').children()[3]).children()[0].click(); | |
e.preventDefault(); | |
} | |
if(e.key === 'n') { | |
$('.new-button')[0].click(); | |
e.preventDefault(); | |
} | |
if(e.key === 'т') { | |
$('.new-button')[0].click(); | |
e.preventDefault(); | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment