Contents

Develop
2003.04.23 10:51

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

Views 7657 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
445 Develop [ios] Locale Identifiers file hooni 2018.11.29 1750
444 Develop [ios] libxml/tree.h file not found file hooni 2013.08.08 18773
443 Develop [ios] iphone SetDeviceOrientation 화면 강제 회전 hooni 2013.11.20 18518
442 Develop [ios] iOS에서 디바이스 종류 알아오기 hooni 2014.05.24 3769
441 Develop [ios] iOS앱의 Xcode 빌드 과정 file hooni 2015.01.03 2409
440 Develop [ios] iOS 의 인앱구매 소개 file hooni 2014.04.29 3911
439 Develop [ios] iOS 앱 아이콘을 만드는 유틸 file hooni 2015.01.03 955
438 Develop [ios] iOS 사운드 관련 프레임워크 hooni 2014.04.18 3084
437 Develop [ios] iOS In App Purchase 코드 부분 샘플 2 hooni 2013.11.20 11340
436 Develop [ios] iOS In App Purchase 코드 부분 샘플 1 hooni 2013.11.20 11806
435 Develop [ios] iOS In App Purchase #2 (코드 구현) file hooni 2013.11.20 13815
434 Develop [ios] iOS In App Purchase #1 (코드 구현 전 웹 설정 작업) file hooni 2013.11.20 14559
Board Pagination Prev 1 ... 29 30 31 32 33 34 35 36 37 38 ... 71 Next
/ 71