Skip to content

capndesign/Blog-Shortcuts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Blog Shortcuts

Author: Matt Jacobs
License: TBD

Overview

Blog Shortcuts provides visitors of your blog the ability to navigate your site with their keyboard.

Requirements

  • jQuery
  • Safari 4.x, Firefox 3.6.x or Chrome 4.x
  • A blog

Usage

There are two files you'll need to include on your blog.

  • blog-shortcuts.js: This is the meat of the application. You'll also do the majority of your configurations here.
  • bs-styles.css: This provides a small set of styles for the help and tag interfaces.

The available shortcuts are listed below and you can configure the key commands for your shortcuts in blog-shortcuts.js. Here's some sample configuration:

// Provide the CSS selector that is unique to your blog posts.
bsOptions.blogPostSelector = '.article';

// Keys for next and previous posts
bsOptions.nextPost = 'j';
bsOptions.prevPost = 'k';

// Key to go to your homepage
// bsOptions.goToHomepage = 'h';

// The URL of your homepage
bsOptions.homepageUrl = '/';

The inline comments should be enough for you to figure it out, but it's worth noting that commenting out any of the shortcuts will keep it from firing (and out of the help menu).

Some usage notes

  • Don't use g. I've reserved that for go-to commands.
  • As such, the "go to tag" command is hard-coded to g then t.
  • You could make the shortcuts the same for navigating between permalinks or through a list of posts. Otherwise, you really shouldn't use the same shortcut twice.

Available Shortcuts

These are the shortcuts that are included.

  • Scroll to the next entry
  • Scroll to the previous entry
  • Load the newer entry on permalink
  • Load the older entry on permalink
  • Go to the homepage
  • Go to reviews
  • Go to archives
  • Go to about
  • Focus on search
  • Go to top
  • Show the tag input window (hardcoded to "g then t" for now)
  • Help menu (which shows all available shortcuts)

See it in action

Right now, the only place it's in use is on my blog. You can see it at capndesign.com.

Known Issues

  • Firefox doesn't like the ? key for some reason. I need to find a workaround
  • It doesn't work in IE 6/7 (maybe 8 and 9 too).

TODO

  • Set jQuery selectors via variables
  • Set keyboard commands via variables
  • Allow character labels instead of character codes
  • Figure out open-source license
  • Get people to help optimize the JS; it could be better

About

Keyboard Shortcuts for your blog

Resources

Stars

Watchers

Forks

Packages

No packages published