mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	finished adding shifted keys (shift+/ <-> ?) to keyboard.js, now full integrated and working in resolver/config and docs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									e3004899f2
								
							
						
					
					
						commit
						075f8ca446
					
				| @ -57,10 +57,7 @@ var KEYBOARD_CONFIG = { | |||||||
| 			}), | 			}), | ||||||
| 		H: 'Esc', | 		H: 'Esc', | ||||||
| 		Q: 'Esc', | 		Q: 'Esc', | ||||||
| 		// '?'
 | 		'?': 'Esc', | ||||||
| 		'/': {  |  | ||||||
| 				shift: 'Esc',  |  | ||||||
| 			}, |  | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -378,12 +375,27 @@ var KEYBOARD_CONFIG = { | |||||||
| 		F4: doc('Open image in external software', openImage), | 		F4: doc('Open image in external software', openImage), | ||||||
| 		E: 'F4', | 		E: 'F4', | ||||||
| 
 | 
 | ||||||
| 		H: doc('Show keyboard bindings', | 		'?': doc('Show keyboard bindings', | ||||||
| 			function(){ toggleKeyboardHelp() }), | 			function(){ toggleKeyboardHelp() }), | ||||||
| 		// '?'
 | 		H: '?', | ||||||
| 		'/': {  | 
 | ||||||
| 				shift: 'H',  | 
 | ||||||
| 			}, | 		/* testing the shift-key feature... | ||||||
|  | 		'~': { | ||||||
|  | 			default: function(){ alert('~') }, | ||||||
|  | 			// this is inaccessible...
 | ||||||
|  | 			shift: function(){ alert('shift-~') }, | ||||||
|  | 			ctrl: function(){ alert('ctrl-~') }, | ||||||
|  | 			'ctrl+alt': function(){ alert('ctrl-alt-~') }, | ||||||
|  | 		}, | ||||||
|  | 		'`': { | ||||||
|  | 			default: function(){ alert('`') }, | ||||||
|  | 			// this is also not accessible as it is shadowed by '''...
 | ||||||
|  | 			shift: function(){ alert('shift-`') }, | ||||||
|  | 			ctrl: function(){ alert('ctrl-`') }, | ||||||
|  | 			'ctrl+alt': function(){ alert('ctrl-alt-`') }, | ||||||
|  | 		}, | ||||||
|  | 		*/ | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -131,12 +131,19 @@ function doc(text, func){ | |||||||
|  * 								'ctrl+shift' |  * 								'ctrl+shift' | ||||||
|  * 							NOTE: 'shift+ctrl' is wrong. |  * 							NOTE: 'shift+ctrl' is wrong. | ||||||
|  * |  * | ||||||
|  |  * This will also resolve several shifted keys by name, for example: | ||||||
|  |  * 'shift-/' is the same as '?', and either can be used, but the shorter  | ||||||
|  |  * direct notation has priority (see _SHIFT_KEYS for supported keys). | ||||||
|  |  * | ||||||
|  |  * | ||||||
|  * Returns: |  * Returns: | ||||||
|  * 	{ |  * 	{ | ||||||
|  * 		<mode>: <handler>, |  * 		<mode>: <handler>, | ||||||
|  * 		... |  * 		... | ||||||
|  * 	} |  * 	} | ||||||
|  * |  * | ||||||
|  |  * | ||||||
|  |  * NOTE: it is not possible to do a shift-? as it is already shifted. | ||||||
|  * NOTE: if a key is not handled in a mode, that mode will not be  |  * NOTE: if a key is not handled in a mode, that mode will not be  | ||||||
|  * 		present in the resulting object. |  * 		present in the resulting object. | ||||||
|  * NOTE: this will not unwrap lisp-style (see below) handlers. |  * NOTE: this will not unwrap lisp-style (see below) handlers. | ||||||
| @ -149,6 +156,7 @@ function doc(text, func){ | |||||||
|  */ |  */ | ||||||
| function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys){ | function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys){ | ||||||
| 	var chr = null | 	var chr = null | ||||||
|  | 	var s_chr = null | ||||||
| 	var did_handling = false | 	var did_handling = false | ||||||
| 	modifiers = modifiers == null ? '' : modifiers | 	modifiers = modifiers == null ? '' : modifiers | ||||||
| 	modes = modes == null ? 'any' : modes | 	modes = modes == null ? 'any' : modes | ||||||
| @ -162,11 +170,10 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys){ | |||||||
| 		key = toKeyCode(key) | 		key = toKeyCode(key) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* XXX this is not done yet... | 	// XXX this is not done yet...
 | ||||||
| 	if(shifted_keys != false && key in shifted_keys){ | 	if(shifted_keys != false && /shift/i.test(modifiers)){ | ||||||
| 		key = shifted_keys[key] | 		var s_chr = shifted_keys[chr] | ||||||
| 	} | 	} | ||||||
| 	*/ |  | ||||||
| 
 | 
 | ||||||
| 	res = {} | 	res = {} | ||||||
| 
 | 
 | ||||||
| @ -183,7 +190,11 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys){ | |||||||
| 
 | 
 | ||||||
| 		var bindings = keybindings[mode] | 		var bindings = keybindings[mode] | ||||||
| 
 | 
 | ||||||
| 		if(chr in bindings){ | 		if(s_chr != null && s_chr in bindings){ | ||||||
|  | 			var handler = bindings[s_chr] | ||||||
|  | 			chr = s_chr | ||||||
|  | 			modifiers = modifiers.replace(/\+?shift/i, '')  | ||||||
|  | 		} else if(chr in bindings){ | ||||||
| 			var handler = bindings[chr] | 			var handler = bindings[chr] | ||||||
| 		} else { | 		} else { | ||||||
| 			var handler = bindings[key] | 			var handler = bindings[key] | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user