Package: django-keyboard-shortcuts
Django-keyboard-shortcutsHelps to use the keyboard inside your web projectThe project code and bugtracker is hosted onBitbucketandGithub.Don’t uses any javascript framework!On the client side you will have only pure javascript code that receives all pre-elaborated and optimized data directly from django.The only dependency is Django itselfJustinstall,configure, and you are ready todominate the worldwith your website keyboard shortcuts.InstallationThere are a few different ways to install keyboard_shortcus:Using pipIf you have pip install available on your system, just type:pip install django-keyboard-shortcutsIf you’ve already got an old version of keyboard_shortcus, and want to upgrade, use:pip install -U django-keyboard-shortcutsInstalling from a directoryIf you’ve obtained a copy of keyboard_shortcus using either Mercurial or a downloadable
archive, you’ll need to install the copy you have system-wide. Try running:python setup.py developIf that fails, you don’t havesetuptoolsor an equivalent installed;
either install them, or run:python setup.py installHow to use keyboard_shortcuts?If you have already installed keyboard_shortcus, you must proceed with the
configuration of your project.Configurationvery simple, in three steps:Addkeyboard_shortcutsTo INSTALLED_APPSModify Your settings.py, declare yourHOTKEYSsettings.Add{% load hotkeys %}{% setup_hotkeys %}in your template.Below the long explanation of each step…Add keyboard_shortcuts To INSTALLED_APPSAs with most Django applications, you should addkeyboard_shortcutsto the INSTALLED_APPS within your settings file (usuallysettings.py).Example:INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',

    # Added.
    'keyboard_shortcuts',
]Modify Your settings.pyWithin yoursettings.py, you’ll need to add some settings in order to assign to desired keyboard shortcuts some actions and to personalize thedjango-keyboard-shortcutsbehaviour for your project.You can define:HOTKEYS- a list containing the desired keyboard combinations and some settings for each (default:list())SPECIAL_DISABLED- a bool, to disable shortcuts in some “special cases”, when an input, a textarea or a select is active (default:True)Example:# START keyboard_shortcuts settings #
HOTKEYS = [
            {'keys': 'g + h',  # go home
            'link': '/'},
        ]
SPECIAL_DISABLED = True
# END keyboard_shortcuts settings #More about HOTKEYS setting?HOTKEYS is a list of dictioanaries. Each dictionary contains the attributes for a particular keyboard combination. HOTKEYS dist must have a key called “keys” and one of “link” or “js”.Examples of “keys” value:“CTRL + R”“Z + R + P”“3 (NUMPAD)”“CTRL + *”“=”Examples of “link” value:“/about/”“http://google.com”Examples of “js” value:“alert(‘HELLO!’);”if for a keyboard combination we have both “link” and “js” declared, only “link” will be condidered.Another advanced examples forHOTKEYSlist:HOTKEYS = [
            {'keys': 'ctrl+h',  # home
            'link': '/',
            },
            {'keys': 'alt+w',
            'link': '/workspace/',
            },
            {'keys': 'shift+j',
            'js': 'js_function();', # javascript code here
            },
            {'keys': 'a+j',
            'js': 'alert(\'A+J Pressed!\');', # javascript code here
            },
            {'keys': '1+2+3',
            'link': '/secret-url/',
            },
        ]Available keys for your combinations:BACKSPACETABENTERSHIFTCTRLALTPAUSECAPSLOCKESCPAGE UPPAGE DOWNENDHOMELEFT ARROWUP ARROWRIGHT ARROWDOWN ARROWINSERTDELETE0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0 (NUMPAD)1 (NUMPAD)2 (NUMPAD)3 (NUMPAD)4 (NUMPAD)5 (NUMPAD)6 (NUMPAD)7 (NUMPAD)8 (NUMPAD)9 (NUMPAD)*+-./F1F2F3F4F5F6F7F8F9F10F11F12NUMLOCKSCROLL=COMMASLASH /BACKSLASH \METASetup Hotkeys In Your TemplateNow all you need to do is to add{% load hotkeys %}and{% setup_hotkeys %}in yout template, anddjango-keyboard-shortcutswill do the rest for you… add event listeners and attend for any keypress.The easiest way to do this is to load hotkeys{% load hotkeys %}at thetopof your “base” template and to setup{% setup_hotkeys %}the in your<head>section.Example of “base.html” template:{% load hotkeys %}
<html>
    <head>
        <title>My title</title>
        {% setup_hotkeys %}
    </head>
    <body>
        my content...
    </body>
</html>How to test keyboard_shortcus?Very simple:$ ./manage.py test keyboard_shortcusDo you need some examples?Further a list of the most useful keyboard shortcuts of our favorite web services.
So, if you need a suggestion about which key combination use on your site,
this is where you find it:Gmailc– compose a new mail/– puts your cursor in the search boxk– move to newer conversationj– Move to older conversationn– next messagep– previous messageo or Enter– open a conversationu– return to conversation listy– archive a conversationm– mute (archive and make all future messages from this conversation
skip the inbox)x– select conversations– star a message or conversation!– report spamr– reply to a maila– reply to all recepientsf– forward messageEsc– escape from input fieldctrl+s– save draftkey combostab then Enter– send messagey then o– archive your conversation and move to the next one.g then a– go to all mailg then s– go to starred conversationsg then c– go to contacts list.g then d– go to draftsg then i– go to inboxGoogle Readerj/k– selects the next/previous item in the listspace/shift-space– moves the page down/upn/p– in list view, selects the next item without opening ito– in list view, expands or collapses the selected itementer– in list view, expands or collapses the selected items– stars the selected itemshift-s– shares the selected itemm– switches the read state of the selected itemt– opens the tagging field for the selected itemv– opens the original source for this article in a new windowshift-a– marks all items in the current view as read1– displays the subscription as expanded items2– displays the subscription as a list of headlinesr– refreshes the unread counts in the navigationshift-n/p– selects the next/previous subscription or folder in the
navigationshift-x– expand or collapse a folder selected in the navigationshift-o– opens the item currently selected in the navigationgh– goes to the Google Reader homepagega– goes to the “All items” viewgs– goes to the “Starred items” viewgt– allows you to navigate to a tag by entering the tag namegu– allows you to navigate to a subscription by entering the
subscription nameu– hides and shows the list of subscriptions?– displays a quick guide to all of Reader’s shortcutsWikipedia+– add a new section (talk pages only).– opens your user page if logged in=– protect/unprotect the current page (sysops only)c– shows the content page associated with the current articled– delete/undelete the current page (sysops only)e– edit this page/show source of current pagef– search Wikipediah– current page’s historyj– shows all of the pages that link to the current onek– shows recent changes in pages linked to the current onel– opens your watchlist (logged – in users only)m– move the current page and its talk page (non – move – protected pages only)n– opens your user’s or IP’s talk pagep– shows a preview of your changes (on edit pages)q– shows a list of all special pagesr– shows a list of recent changes to the Wikipedias– saves the changes that you have made (on edit pages)t– opens the current article’s talk pageu– allows you to upload images or media filesv– shows what changes you made to the text (on edit pages)w– adds the current page to your watchlist (logged – in users only)x– loads a random articley– opens a list of your user’s or IP’s contributionsz– goes to the Main PageYahoo! Mailm– check mailShift+m– check all mailCtrl+– close current tabn– new messageShift+n– new message in its own windowr– replyShift+r– reply in a new windowa– reply allShift+a– reply all in a new windowf– forward messageShift+f– forward in a new windowk– mark as readShift+k– mark as unreadl– flagShift+l– clear flagdel– delete itemp/Ctrl+p– printCtrl+s– save draftCtrl+Enter– send messagev– turn reading pane on/offCtrl+[– navigate through tabsCtrl+]– navigate through tabsEnter– open message in its own tab (when message is selected)Enter– edit contact info (when contact is selected)Ctrl+f– find a word or phrase in messageF11– expand window to max heightCtrl+.– next message (in message tab)Ctrl+,– previous message (in message tab)Ctrl+Alt+Shift+up arrow/down arrow– next/previous messageCtrl+Shift+End– skip to oldest unread messaged– move message to folderEsc– close read** – message tabCtrl+Shift+End– start a new chatCreditsSpecial thanks to the authors of this resources:http://www.w3.org/2002/09/tests/keys.htmlhttp://www.quirksmode.org/js/keys.html#t00http://unixpapa.com/js/key.htmlhttp://www.openjs.com/scripts/events/keyboard_shortcuts/https://github.com/jeresig/jquery.hotkeys/http://mashable.com/2007/06/29/keyboard-shortcuts/Changelog0.0.7added support for “js” action for your shortcutscovered with tests the new functionalityimproved documentation0.0.6you can now configure in your settings.py the behaviour in “special cases”updated the documentationimproved tests0.0.5disabled hotkeys in selet and text type inputs0.0.4now you can add multiple key combinationsimproved testsupdated the documentation0.0.3included “keyboard_shortcuts/templates *” in MANIFEST.indocumentation updatedtemplatetags and utils are now tested0.0.2added hotkeys templatetagadded an example project for testing purposes0.0.1initial structure