Skip to content
mooz edited this page Feb 3, 2011 · 45 revisions

KeySnail

For Vim users, there is Vimperator. For Emacs users, there is KeySnail.

Installation

Download keysnail.xpi from the link below.

KeySnail for Firefox KeySnail for Thunderbird (beta)

After that, drag keysnail.xpi and drop it to the Firefox or Thunderbird. Then you can install the KeySnail following instructions.

Or from the command line,

$ wget https://github.com/mooz/keysnail/raw/master/keysnail.xpi
$ firefox keysnail.xpi

What’s this?

KeySnail allows you to bind functions to key sequences

This extension provides very flexible way of customizing the keybindings.

You can define or choose the arbitrary function written in JavaScript, and bind it to the arbitrary key sequence through the initialization file.

Preference dialog

Yes, this extension allows you to bind functions to the key sequence not just the shortcut key.

KeySnail provides many functions which emulates Emacs behavior

For Emacs junkies, KeySnail provides a lot of commands and functions which emulate the Emacs behavior.

Part of features are listed below.

  • Customization through the init file
    • You may know .emacs file if you are the emacs user. KeySnail use .keysnail.js file which corresponds to that for customizing.
  • Keyboard macro
    • Record tedious work by pressing F3 and repeat it by pressing F4 (Of course, you can customize the key bindings).
  • Kill ring
    • KeySnail provides multiple clipboards to the Firefox. Press C-y to yank and M-y to yank pop. C-M-y allows you to list and insert items in kill ring.
  • Prefix argument system
    • C-u, M—, C-M-3, make commands more flexible.
  • Prompt system
    • You know completing-read in emacs lisp. KeySnail’s prompt.read() and prompt.reader() correspond to that.
  • Selector system
    • Do you know anything.el the awesome package which makes emacs more powerful? KeySnail’s prompt.selector() is very inspired from anything.el and allows you to select bookmarks, tabs and anything given.
  • M-x
    • By pressing M-x (Or other keys you like), you can call various commands which you registered in your .keysnail.js file or provided by plugins.

KeySnail is the environment

KeySnail has the plugin system which allows user to extends KeySnail with lot of features.

Plugin system

Plugins makes your Firefox and KeySnail life more special.

  • KeySnail becomes the twitter client. (Yet Another Twitter Client KeySnail)
  • Edit textareas with Emacs (or other editors you like) (K2Emacs)
  • Mouse-less browsing with very powerful Hit a Hint plugin (HoK)
  • Prefer shortcut keys of Gmail, Google Reader, and other sites (Site local keymap + Prefer LDRize)

Find plugins

If you are the Firefox extension developer or familiar with the userChrome.js, it’s easy to start writing the KeySnail plugins.

See Writing Plugins for details.

Init file format

KeySnail loads the .keysnail.js / _keysnail.js from user home directory (or a profile directory in Windows) and execute it. This directory can be changed in the preference dialog.

Init file is the complete JavaScript program. You can call JavaScript / Firefox API and moreover, other extensions function.

You can bind the function to the key sequence, using the functions listed below.

key.setGlobalKey(keys, func, ksDescription, ksNoRepeat);
key.setEditKey(keys, func, ksDescription, ksNoRepeat);
key.setViewKey(keys, func, ksDescription, ksNoRepeat);
key.setCaretKey(keys, func, ksDescription, ksNoRepeat);

Here are the descriptions of the each argument.

keys

Specify key (string) or key sequence (array). if you want to bind a function to mutliple key sequence use ‘array of array’. The expression of the key follows the Emacs like below example.

Ctrl + Alt + t C-M-t
Arrow Key <up>, <down>, <left>, <right>
PgUp, PgDn <prior>, <next>
F1, F2, F3 <f1>, <f2>, <f3>

func

Specify anonymous function. This function can take two arguments.

  • argument 1 => key event
  • argument 2 => prefix argument (or null)

You can use these arguments through declaring the following expression.

function (aEvent, aArg)

ksDescription

Specify description of the function. You can omit this argument.

ksNoRepeat

When this value is false, command (function) is executed prefix arguments times.

If you want to use prefix argument in your function and do not want to repeat it, set this value to true.

you can omit this argument.

Icons by taytel