New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

oncapslock

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oncapslock

A simple, lightweight JavaScript event plugin for detecting user input with caps lock on, with support for jQuery.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

jquery.oncapslock

A simple, lightweight JavaScript event plugin for detecting user input with caps lock on, with support for jQuery.

jQuery is not required, but if you do use it, the plugin requires version >= 1.7

Tested on modern browsers and IE8.

Installation

With bower:

bower install oncapslock

With npm:

npm install oncapslock

Manually:

Download dist/oncapslock.min.js and include it

Usage

with jQuery

// With jQuery usage is rather straightforward

$('#selector').on('capslock', function (e) {

    alert('You are typing with Caps Lock on!');

});

Vanilla JS

// Without jQuery things get a bit complicated if you intend to support IE8

if (typeof document.addEventListener === 'function') {

	// Modern browsers work as expected
	document.getElementById('example').addEventListener('capslock', yourHandler);

} else {

	// Older IEs don't support custom events, so we'll piggyback on another event
	document.getElementById('example').attachEvent('onpropertychange',
		function(e) {
			
			// You'll have to check that it was actually fired because of caps
			if (e.eventType === 'capslock') {
				yourHandler(e);
			}
		}
	);
}

alternative approach without jQuery

document.getElementById('example').oncapslock = function(e) {
	alert('You are typing with Caps Lock on!');
};

Keywords

capslock

FAQs

Package last updated on 21 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts