jQueryでホットキーするメモ

このエントリーを含むはてなブックマーク

jQueryでホットキーを処理するメモ

どの入力フォームにもフォーカスしていない場合 nとpで特定の処理を実行するサンプル

  1. $(this).keypress(
  2.   function(e)
  3.   {
  4.     if( $.inArray(e.target,$('input')) <0 )
  5.     {
  6.       if( e.which==112 )
  7.       {
  8.         hoge();
  9.       }
  10.       else if( e.which==110 )
  11.       {
  12.         foo();
  13.       }
  14.     }
  15.   }
  16. )


Posted in javascript, jquery, 日記 at 2月 1st, 2008. Trackback URI: trackback

No Responses to “jQueryでホットキーするメモ”

Leave a Reply