20110126

jQuery KEY event control

// KEY CODE

_.special_keys = {

27:'esc',

9:'tab',

32:'space',

13:'enter',

8:'backspace',

145:'scroll_lock',

20:'caps_lock',

144:'num_lock',

19:'pause',

45:'insert',

36:'home',

46:'delete',

35:'end',

33:'page_up',

34:'page_down',

37:'left',

38:'up',

39:'right',

40:'down',

112:'f1',

113:'f2',

114:'f3',

115:'f4',

116:'f5',

117:'f6',

118:'f7',

119:'f8',

120:'f9',

121:'f10',

122:'f11',

123:'f12',

};

_.shift_nums = {

"`":"~",

"1":"!",

"2":"@",

"3":"#",

"4":"$",

"5":"%",

"6":"^",

"7":"&",

"8":"*",

"9":"(",

"0":")",

"-":"_",

"=":"+",

";":":",

"'":"\"",

",":"<",

".":">",

"/":"?",

"\\":"|"

};


//disable key:tab

root.find("button.next").keydown(function(e) {

if (e.keyCode == 9 ) {

return false;

}

});


//Bind this keypress function to all of the input tags
//http://jelaniharris.com/2010/using-jquery-to-disable-the-enter-key/ 

$("input").keypress(function (evt) {
 //Deterime where our character code is coming from within the event 
  var charCode = evt.charCode || evt.keyCode;
  if (charCode  == 13) { 
    //Enter key's keycode 
    return false; 
  } 
});


沒有留言:

張貼留言