PageSourceSearch

https://www.wsge.org/wp-content/themes/gaston-radio/js/jquery.simulate.key-combo.js?ver=1.0

js wsge.org collected 2026-09-25 20:56:15 UTC 4,101 bytes, 158 lines download raw bytes

1/*jshint camelcase:true, plusplus:true, forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, unused:true, curly:true, browser:true, devel:true, maxerr:100, white:false, onevar:false */
2/*jslint white: true vars: true browser: true todo: true */
3/*global jQuery:true $:true */
4
5/* jQuery Simulate Key-Combo Plugin 1.2.0
6 * http://github.com/j-ulrich/jquery-simulate-ext
7 * 
8 * Copyright (c) 2013 Jochen Ulrich
9 * Licensed under the MIT license (MIT-LICENSE.txt).
10 */
11
12/**
13 * 
14 * For details about key events, key codes, char codes etc. see http://unixpapa.com/js/key.html
15 */
16
17;(function($,undefined) {
18	"use strict";
19
20	/**
21	 * Key codes of the modifier keys.
22	 * @private
23	 * @author julrich
24	 * @since 1.0
25	 */
26	var ModifierKeyCodes = {
27		SHIFT:		16,
28		CONTROL:	17,
29		ALT:		18,
30		COMMAND:	91
31	};
32
33	$.extend( $.simulate.prototype,
34			
35	/**
36	 * @lends $.simulate.prototype
37	 */		
38	{
39		
40		
41		/**
42		 * Simulates simultaneous key presses
43		 * 
44		 * @see https://github.com/j-ulrich/jquery-simulate-ext/blob/master/doc/key-combo.md
45		 * @public
46		 * @author julrich
47		 * @since 1.0
48		 */
49		simulateKeyCombo: function() {
50			var target = $(this.target),
51				options = $.extend({
52					combo: "",
53					eventsOnly: false
54				}, this.options),
55				eventOptions = {},
56				combo = options.combo,
57				comboSplit = combo.split(/(\+)/),
58				plusExpected = false,
59				holdKeys = [],
60				i;
61			
62			if (combo.length === 0) {
63				return;
64			}
65				
66			
67			// Remove empty parts
68			comboSplit = $.grep(comboSplit, function(part) {
69				return (part !== "");
70			});
71			
72			for (i=0; i < comboSplit.length; i+=1) {
73				var key = comboSplit[i],
74					keyLowered = key.toLowerCase();
75				
76				if (plusExpected) {
77					if (key !== "+") {
78						throw 'Syntax error: expected "+"';
79					}
80				}
81				else {
82					var keyCode;
83					switch (keyLowered) {
84					case "ctrl":
85					case "alt":
86					case "shift":
87					case "meta":
88						switch (keyLowered) {
89						case "ctrl":	keyCode = ModifierKeyCodes.CONTROL; break;
90						case "alt":		keyCode = ModifierKeyCodes.ALT; break;
91						case "shift":	keyCode = ModifierKeyCodes.SHIFT; break;
92						case "meta":	keyCode = ModifierKeyCodes.COMMAND; break;
93						}
94						eventOptions[keyLowered+"Key"] = true;
95						holdKeys.unshift(keyCode);
96						eventOptions.keyCode = keyCode;
97						target.simulate("keydown", eventOptions);
98						break;
99					default:
100						if (key.length > 1) {
101							throw 'Syntax error: expecting "+" between each key';
102						}
103						else {
104							keyCode = $.simulate.prototype.simulateKeySequence.prototype.charToKeyCode(key);
105							holdKeys.unshift(keyCode);
106							eventOptions.keyCode = keyCode;
107							eventOptions.which = keyCode;
108							eventOptions.charCode = undefined;
109							target.simulate("keydown", eventOptions);
110							if (eventOptions.shiftKey) {
111								key = key.toUpperCase();
112							}
113							eventOptions.keyCode = key.charCodeAt(0);
114							eventOptions.charCode = eventOptions.keyCode;
115							eventOptions.which = eventOptions.keyCode;
116							target.simulate("keypress", eventOptions);
117							if (options.eventsOnly !== true && !eventOptions.ctrlKey && !eventOptions.altKey && !eventOptions.metaKey) {
118								target.simulate('key-sequence', {sequence: key, triggerKeyEvents: false});
119							}
120						}
121						break;
122					}
123				}
124					
125				plusExpected = !plusExpected;
126			}
127			
128			if (!plusExpected) {
129				throw 'Syntax error: expected key (trailing "+"?)';
130			}
131			
132			// Release keys
133			eventOptions.charCode = undefined;
134			for (i=0; i < holdKeys.length; i+=1) {
135				eventOptions.keyCode = holdKeys[i];
136				eventOptions.which = holdKeys[i];
137				switch (eventOptions.keyCode) {
138				case ModifierKeyCodes.ALT:
139					eventOptions.altKey = false;
140					break;
141				case ModifierKeyCodes.SHIFT:
142					eventOptions.shiftKey = false;
143					break;
144				case ModifierKeyCodes.CONTROL:
145					eventOptions.ctrlKey = false;
146					break;
147				case ModifierKeyCodes.COMMAND:
148					eventOptions.metaKey = false;
149					break;
150				default:
151					break;
152				}
153				target.simulate("keyup", eventOptions);				
154			}
155		}
156		
157	});
158}(jQuery));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.