m.input.js

This part of the module is responsible for abstracting various input events in such a way that they are more flexible beyond their intended use. Most notably, that means wrapping the event handlers for keyboard events, so as to prevent rapid emission of redundant key press events.

Functionality is also provided for allowing automatic mappings for different keyboard layouts.

This file stores most of its API under the please.keys object.

please.keys.enable

please.keys.enable ()

This function hooks up the necessary event handling machinery.

please.keys.disable

please.keys.disable ()

This function removes the necessary event handling machinery.

please.connect

please.connect (char, handler, threshold)

Adds a keyboard binding.

please.keys.remove

please.keys.remove (char)

Removes a keybinding set by please.keys.connect.

please.keys.normalize_dvorak

please.keys.normalize_dvorak (str)

This function converts strings between qwerty and dvorak. This is used to convert keyboard events for Dvorak users to Qwerty for the purpose of recognizing events and having a common notation (Qwerty) for determining the likely physical placement of various keys.

  • str A string containing a string of text as if it were typed on a dvorak key layout.
var asd = please.keys.normalize_dvorak("aoe");

please.keys.lookup_keycode

please.keys.lookup_keycode (code)

This function returns a human readable identifier for a given keycode. This is used because string.fromCharCode does not always produce correct results.

This function will automatically perform keyboard layout conversion, if the keyboard layout is appended to the document URL. Currently, only #dvorak is supported.

  • code Numerical character code value.

please.keys.__cancel

please.keys.__cancel (char)

Forces a key to be released.

please.keys.__full_stop

please.keys.__full_stop ()

This function is called to force key-up events and clear all pending input timeouts. Usually this happens when the window is blurred.