Kaddy
Kaddy

Reputation: 1266

Need to modify yui 'key press' event handling

I want to make some modification to the key.js file to be able to handle modifiers other than "shift", "alt", "ctrl", or "meta i.e. something like this 'down:50+alt+49' (altkey+onekey+towkey)should also work.

[url]http://yuilibrary.com/yui/docs/event/key.html[/url]

How can i make changes to this file and make sure the modified file is used when i call

YUI().use("event-key", function(Y) { Y.on('key', function() {console.log('test'); }, '#my-input-element', 'down:50+alt+49');

Thanks in advance. KD

Upvotes: 0

Views: 698

Answers (2)

Kevin Lamping
Kevin Lamping

Reputation: 2269

Instead of overwriting the core YUI JS (which can cause trouble down the road when updating YUI), have you considered creating a synthetic event for that specific keystroke combination?

Examples/Documentation here:

Upvotes: 1

Satyam
Satyam

Reputation: 96

The easiest way is to load your modified file through a tag right after loading yui-min.js and before calling YUI().use. When your file is loaded, if it has the same name as the original in the YUI.add() wrapper, the loader will know the requirement for 'event-key' is fulfilled and it will not load the version from the Yahoo sites. It will, however, fill in the dependencies it needs.

Upvotes: 0

Related Questions