추가한 단축키는 아래와 같습니다.
추가한 단축키
- E - 본문 수정하기
- T - 본문 수정하기 (Pop up)
- W - 새 글 쓰기
이를 위해서는 적당한 이벤트 핸들러를 만들어서 키보드 해당 키가 눌려졌을 때 만들어둔 핸들러를 연결시켜 주면 됩니다. 자세한건 아래 구현을 참조하세요.
1. 스크립트 추가 : <head>~</head>에 추가
<script type="text/javascript" language="javascript">
<!--
function hotkeyCommon1(){
if(event.srcElement) {
evt = window.event;
target = window.event.srcElement;
}
else {
evt = event;
target = event.target;
}
if (evt.altKey || evt.ctrlKey) {
return null;
}
switch (target.nodeName) {
case "INPUT":
case "SELECT":
case "TEXTAREA":
return null;
}
return evt;
}
function hotkeyCommon2(evt){
switch(evt.keyCode) {
case 87: // W
window.open("/admin/entry/post", "_top");
break;
}
}
function postHotkey(){
if((evt=hotkeyCommon1()) == null) {
return;
}
path = location.pathname.substr(1);
switch(evt.keyCode) {
case 69: // E
window.open("/admin/entry/edit/" + path + "?returnURL=/" + path, "_top");
break;
case 84: // T
editEntry(path,"/"+path);
break;
default:
hotkeyCommon2(evt)
break;
}
}
function mainHotkey(){
if((evt=hotkeyCommon1()) == null) {
return;
}
hotkeyCommon2(evt)
}
-->
</script>
<!--
function hotkeyCommon1(){
if(event.srcElement) {
evt = window.event;
target = window.event.srcElement;
}
else {
evt = event;
target = event.target;
}
if (evt.altKey || evt.ctrlKey) {
return null;
}
switch (target.nodeName) {
case "INPUT":
case "SELECT":
case "TEXTAREA":
return null;
}
return evt;
}
function hotkeyCommon2(evt){
switch(evt.keyCode) {
case 87: // W
window.open("/admin/entry/post", "_top");
break;
}
}
function postHotkey(){
if((evt=hotkeyCommon1()) == null) {
return;
}
path = location.pathname.substr(1);
switch(evt.keyCode) {
case 69: // E
window.open("/admin/entry/edit/" + path + "?returnURL=/" + path, "_top");
break;
case 84: // T
editEntry(path,"/"+path);
break;
default:
hotkeyCommon2(evt)
break;
}
}
function mainHotkey(){
if((evt=hotkeyCommon1()) == null) {
return;
}
hotkeyCommon2(evt)
}
-->
</script>
2. 이벤트 추가 - 모든 페이지 용
변경 전:
<body ...
변경 후:
<body onkeydown="mainHotkey();" ...
3. 이벤트 추가 - 본문 페이지 용
변경 전:
<s_article_rep>
....
....
변경 후:
<s_article_rep>
<script>document.body.onkeydown = postHotkey;</script>
....
<script>document.body.onkeydown = postHotkey;</script>
....
추가적인 단축키를 구현하려면 스크립트 소스를 적당히 수정하면 됩니다.
어쨌든, 이로써 좀더 편안하게 블로깅을 할 수 있을듯 합니다.
'General > Tip For Programming' 카테고리의 다른 글
| [용어정리] Argument - IT용어 (0) | 2010.10.01 |
|---|---|
| 영화릴 용어 정리 (0) | 2010.05.05 |
| Windows 7 단축키 (0) | 2009.12.14 |
| 티스토리(tistory) 단축키 (0) | 2009.12.14 |
| [VS] Visual Studio 2008 SP 1 Download url (0) | 2009.12.02 |