mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	This commit was originally automatically generated using `tools/lint --only=eslint --fix`. It was then modified by tabbott to contain only changes to a set of files that are unlikely to result in significant merge conflicts with any open pull request, excluding about 20 files. His plan is to merge the remaining changes with more precise care, potentially involving merging parts of conflicting pull requests before running the `eslint --fix` operation. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
		
			
				
	
	
		
			41 lines
		
	
	
		
			743 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			743 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/*
 | 
						|
    See hotkey.js for handlers that are more app-wide.
 | 
						|
*/
 | 
						|
 | 
						|
const keys = {
 | 
						|
    13: 'enter_key',
 | 
						|
    37: 'left_arrow',
 | 
						|
    38: 'up_arrow',
 | 
						|
    39: 'right_arrow',
 | 
						|
    40: 'down_arrow',
 | 
						|
};
 | 
						|
 | 
						|
exports.handle = function (opts) {
 | 
						|
    opts.elem.keydown(function (e) {
 | 
						|
        const key = e.which || e.keyCode;
 | 
						|
 | 
						|
        if (e.altKey || e.ctrlKey || e.shiftKey) {
 | 
						|
            return;
 | 
						|
        }
 | 
						|
 | 
						|
        const key_name = keys[key];
 | 
						|
 | 
						|
        if (!key_name) {
 | 
						|
            return;
 | 
						|
        }
 | 
						|
 | 
						|
        if (!opts.handlers[key_name]) {
 | 
						|
            return;
 | 
						|
        }
 | 
						|
 | 
						|
        const handled = opts.handlers[key_name]();
 | 
						|
 | 
						|
        if (handled) {
 | 
						|
            e.preventDefault();
 | 
						|
            e.stopPropagation();
 | 
						|
        }
 | 
						|
    });
 | 
						|
};
 | 
						|
 | 
						|
window.keydown_util = exports;
 |