@@ -729,5 +729,86 @@ describe('KittyKeyboard', () => {
729729 assert . strictEqual ( result . key , '\x1b[57440u' ) ;
730730 } ) ;
731731 } ) ;
732+
733+ describe ( 'macOS Option as Alt (macOptionIsMeta)' , ( ) => {
734+ const flags = KittyKeyboardFlags . DISAMBIGUATE_ESCAPE_CODES ;
735+ const press = KittyKeyboardEventType . PRESS ;
736+
737+ it ( 'Opt+f (key=ƒ) → CSI 102;3 u' , ( ) => {
738+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' , altKey : true } ) , flags , press , true ) ;
739+ assert . strictEqual ( result . key , '\x1b[102;3u' ) ;
740+ } ) ;
741+
742+ it ( 'Opt+b (key=∫) → CSI 98;3 u' , ( ) => {
743+ const result = kitty . evaluate ( createEvent ( { key : '∫' , code : 'KeyB' , altKey : true } ) , flags , press , true ) ;
744+ assert . strictEqual ( result . key , '\x1b[98;3u' ) ;
745+ } ) ;
746+
747+ it ( 'Opt+d (key=∂) → CSI 100;3 u' , ( ) => {
748+ const result = kitty . evaluate ( createEvent ( { key : '∂' , code : 'KeyD' , altKey : true } ) , flags , press , true ) ;
749+ assert . strictEqual ( result . key , '\x1b[100;3u' ) ;
750+ } ) ;
751+
752+ it ( 'Opt+n dead key (key=Dead, code=KeyN) → CSI 110;3 u' , ( ) => {
753+ const result = kitty . evaluate ( createEvent ( { key : 'Dead' , code : 'KeyN' , altKey : true } ) , flags , press , true ) ;
754+ assert . strictEqual ( result . key , '\x1b[110;3u' ) ;
755+ } ) ;
756+
757+ it ( 'Opt+e dead key (key=Dead, code=KeyE) → CSI 101;3 u' , ( ) => {
758+ const result = kitty . evaluate ( createEvent ( { key : 'Dead' , code : 'KeyE' , altKey : true } ) , flags , press , true ) ;
759+ assert . strictEqual ( result . key , '\x1b[101;3u' ) ;
760+ } ) ;
761+
762+ it ( 'Opt+u dead key (key=Dead, code=KeyU) → CSI 117;3 u' , ( ) => {
763+ const result = kitty . evaluate ( createEvent ( { key : 'Dead' , code : 'KeyU' , altKey : true } ) , flags , press , true ) ;
764+ assert . strictEqual ( result . key , '\x1b[117;3u' ) ;
765+ } ) ;
766+
767+ it ( 'Opt+5 (key=∞) → CSI 53;3 u' , ( ) => {
768+ const result = kitty . evaluate ( createEvent ( { key : '∞' , code : 'Digit5' , altKey : true } ) , flags , press , true ) ;
769+ assert . strictEqual ( result . key , '\x1b[53;3u' ) ;
770+ } ) ;
771+
772+ it ( 'Opt+Shift+f (key=Ï) → CSI 102;4 u' , ( ) => {
773+ const result = kitty . evaluate ( createEvent ( { key : 'Ï' , code : 'KeyF' , altKey : true , shiftKey : true } ) , flags , press , true ) ;
774+ assert . strictEqual ( result . key , '\x1b[102;4u' ) ;
775+ } ) ;
776+
777+ it ( 'Ctrl+Opt+f (key=ƒ) → CSI 102;7 u' , ( ) => {
778+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' , altKey : true , ctrlKey : true } ) , flags , press , true ) ;
779+ assert . strictEqual ( result . key , '\x1b[102;7u' ) ;
780+ } ) ;
781+
782+ it ( 'does not unwind when macOptionAsAlt is false (Linux Alt is a chord)' , ( ) => {
783+ const result = kitty . evaluate ( createEvent ( { key : 'a' , code : 'KeyA' , altKey : true } ) , flags , press , false ) ;
784+ assert . strictEqual ( result . key , '\x1b[97;3u' ) ;
785+ } ) ;
786+
787+ it ( 'does not unwind on Linux AZERTY (key=a, code=KeyQ) — uses ev.key not ev.code' , ( ) => {
788+ const result = kitty . evaluate ( createEvent ( { key : 'a' , code : 'KeyQ' , altKey : true } ) , flags , press , false ) ;
789+ assert . strictEqual ( result . key , '\x1b[97;3u' ) ;
790+ } ) ;
791+
792+ it ( 'does not unwind when macOptionAsAlt is false even with composed key' , ( ) => {
793+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' , altKey : true } ) , flags , press , false ) ;
794+ assert . strictEqual ( result . key , '\x1b[402;3u' ) ;
795+ } ) ;
796+
797+ it ( 'does not unwind when altKey is false' , ( ) => {
798+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' } ) , flags , press , true ) ;
799+ assert . strictEqual ( result . key , 'ƒ' ) ;
800+ } ) ;
801+
802+ it ( 'falls through when ev.code is not Key*/Digit* (Opt+;)' , ( ) => {
803+ const result = kitty . evaluate ( createEvent ( { key : '…' , code : 'Semicolon' , altKey : true } ) , flags , press , true ) ;
804+ assert . strictEqual ( result . key , '\x1b[8230;3u' ) ;
805+ } ) ;
806+
807+ it ( 'Opt+f release with REPORT_EVENT_TYPES → CSI 102;3:3 u' , ( ) => {
808+ const releaseFlags = KittyKeyboardFlags . DISAMBIGUATE_ESCAPE_CODES | KittyKeyboardFlags . REPORT_EVENT_TYPES ;
809+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' , altKey : true } ) , releaseFlags , KittyKeyboardEventType . RELEASE , true ) ;
810+ assert . strictEqual ( result . key , '\x1b[102;3:3u' ) ;
811+ } ) ;
812+ } ) ;
732813 } ) ;
733814} ) ;
0 commit comments