Contents

Develop
2003.04.23 10:51

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

Views 7654 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
841 Develop '2014 모바일 개발 트렌드' 발표자료입니다. file hooni 2014.10.02 1138
840 Develop Aspect Oriented Programming in Objective-C hooni 2015.05.18 949
839 Develop DDay Memo 1.9.4 소스코드 secret hooni 2015.10.03 0
838 Develop GCM 사용하기 2 (단말에 GCM 구현하기) file hooni 2013.07.06 23412
837 Develop GCM 사용하기 3 (JSP로 GCM 푸시 서버 만들기) 4 file hooni 2013.07.06 25428
836 Develop git 브런치 배우기 (링크) hooni 2013.07.09 20702
835 Develop GPL, AGPL, MPL,.. 한눈에 보는 오픈소스SW 라이선스 file hooni 2014.10.14 1267
834 Develop How to Test SMTP AUTH using Telnet hooni 2018.04.05 1590
833 Develop JSON, BSON 변환 file hooni 2013.04.23 11874
832 Develop Laravel 5 Failed opening required bootstrap/../vendor/autoload.php hooni 2018.01.24 1836
831 Develop Mac OS 에 Jenkins 설치하기 (Homebrew) 2 file hooni 2017.03.15 8398
830 Develop macOS에 node, npm 설치하기 (homebrew) file hooni 2021.11.06 1460
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 71 Next
/ 71