Contents

Develop
2003.04.23 10:51

[js] 핫키(단축키) 구현방법

Views 7649 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
웹 페이지 상에서 특정 행동을 수행하기 위한 단축 키를 보통 핫 키(Hot Key)라고 부른다. 예를 들어, 현재 페이지 상에서 "k" 키를 누르면 코리아인터넷닷컴 홈페이지로 이동할 수 있도록 스크립트를 작성할 수가 있다. 물론, 응용하기에 따라 다양한 효과를 구현할 수 있을 것이다. 다음과 같은 예를 한 번 살펴 보자: 

<SCRIPT LANGUAGE="JavaScript1.2"> 
<!-- 

var NS = (window.Event) ? 1 : 0 
function checkKey(e) { 
    var code = (NS) ? e.which : event.keyCode; 
    var key = String.fromCharCode(code); 
    for (var i = 0{ 
        if (key == ar[i].key) location.href = ar[i].url; 
    } 

function hotKey(key, url) { 
    this.key = key; 
    this.url = url; 

if (NS) document.captureEvents(Event.KEYPRESS) 
    document.onkeypress = checkKey; 

var ar = new Array(); 
ar[ar.length] = new hotKey("k", "http://korea.internet.com/"); 
ar[ar.length] = new hotKey("j", "http://korea.internet.com/channel/list.asp?cid=189&zid=8"); 
ar[ar.length] = new hotKey("h", "http://korea.internet.com/channel/list.asp?cid=187&zid=8"); 

// --> 
</SCRIPT>   

위와 같은 방법으로 다양한 핫키를 정의할 수가 있다. 이런 정의는 인터넷 익스플로러 4.x 이상과 넷스케이프 내비게이터 4.x 이상에서만 사용할 수가 있다.  

현재 페이지에서 j키, h키, k키를 각각 눌러 보기 바란다. 아마도 해당 페이지로 이동하게 될 것이다.


?

List of Articles
No. Category Subject Author Date Views
85 Develop [ios] 동영상 플레이어 샘플 (for Local File) file hooni 2017.02.07 1179
84 Develop [ios][swift] 초간단 To-do Memo file hooni 2016.06.27 1172
83 Develop [ios] Did UIScrollView End Scrolling? hooni 2016.04.19 1159
82 Develop [ios] 상위 ViewController 가져오기 hooni 2015.10.12 1150
81 Develop [ios] StoryBoard(xib) 없이 프로젝트 만들기 file hooni 2015.02.12 1146
80 Develop [ios] 로컬에 있는 html 실행하기 hooni 2015.02.10 1130
79 Develop '2014 모바일 개발 트렌드' 발표자료입니다. file hooni 2014.10.02 1125
78 Develop [c] FSN 온라인 코딩 테스트 (Sorting, Binary Search) file hooni 2015.06.26 1122
77 Develop [ios] Xcode의 디버그 모드에서 콜스택 file hooni 2015.01.03 1098
76 Develop [js] 스크롤 이벤트 막기 hooni 2015.04.14 1077
75 Develop [ios] APNS, Remote Push 수신 시점에서 앱의 3가지 실행 상태 hooni 2018.10.19 1073
74 Develop [ubuntu] 우분투 18.04에 PHP5 설치하기 hooni 2020.11.14 1072
Board Pagination Prev 1 ... 59 60 61 62 63 64 65 66 67 68 ... 71 Next
/ 71