mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	We ignore keystrokes like alt-left-arrow and alt-right-arrow, so that the browser can do back/forward. We may need to refine the handling of ctrl/alt/shift in the future, but now we only support single-key operations.
		
			
				
	
	
		
			38 lines
		
	
	
		
			669 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			669 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
set_global('$', global.make_zjquery());
 | 
						|
 | 
						|
zrequire('keydown_util');
 | 
						|
 | 
						|
run_test('test_early_returns', () => {
 | 
						|
    const stub = $.create('stub');
 | 
						|
    const opts = {
 | 
						|
        elem: stub,
 | 
						|
        handlers: {
 | 
						|
            left_arrow: () => {
 | 
						|
                throw Error('do not dispatch this with alt key');
 | 
						|
            },
 | 
						|
        },
 | 
						|
    };
 | 
						|
 | 
						|
    keydown_util.handle(opts);
 | 
						|
    const keydown_f = stub.keydown;
 | 
						|
 | 
						|
    const e1 = {
 | 
						|
        which: 17, // not in keys
 | 
						|
    };
 | 
						|
 | 
						|
    keydown_f(e1);
 | 
						|
 | 
						|
    const e2 = {
 | 
						|
        which: 13, // no handler
 | 
						|
    };
 | 
						|
 | 
						|
    keydown_f(e2);
 | 
						|
 | 
						|
    const e3 = {
 | 
						|
        which: 37,
 | 
						|
        altKey: true, // let browser handle
 | 
						|
    };
 | 
						|
 | 
						|
    keydown_f(e3);
 | 
						|
});
 |