这是如何指定此类布局的:
<?xml version="1.1" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<keyboard group="126" id="-31675" maxout="1" name="Math Unicode Layout">
<layouts>
<layout first="0" last="4" mapSet="fb0" modifiers="84"/>
<layout first="5" last="5" mapSet="18c" modifiers="84"/>
<layout first="8" last="9" mapSet="18c" modifiers="84"/>
<layout first="13" last="13" mapSet="18c" modifiers="84"/>
</layouts>
<modifierMap defaultIndex="0" id="84">
<keyMapSelect mapIndex="0">
<modifier keys=""/>
<modifier keys="rightShift? rightOption rightControl"/>
<modifier keys="rightShift rightOption? rightControl"/>
</keyMapSelect>
<keyMapSelect mapIndex="1">
<modifier keys="anyShift"/>
<modifier keys="shift rightShift? caps? rightOption? rightControl"/>
<modifier keys="shift rightShift? caps? rightOption rightControl?"/>
<modifier keys="shift rightShift? caps rightOption? rightControl?"/>
</keyMapSelect>
这是 DTD(来自/System/Library/DTDs/KeyboardLayout.dtd
):
<!-- Overall structure -->
<!ELEMENT keyboard (layouts+, modifierMap+, keyMapSet+, actions*, terminators*)>
<!ATTLIST keyboard group NMTOKEN #REQUIRED >
<!ATTLIST keyboard id NMTOKEN #REQUIRED >
<!ATTLIST keyboard name CDATA #REQUIRED >
<!ATTLIST keyboard maxout NMTOKEN #IMPLIED >
<!-- Hardware layout elements -->
<!ELEMENT layouts (layout+) >
<!ELEMENT layout EMPTY >
<!ATTLIST layout first NMTOKEN #REQUIRED >
<!ATTLIST layout last NMTOKEN #REQUIRED >
<!ATTLIST layout modifiers IDREF #REQUIRED >
<!ATTLIST layout mapSet IDREF #REQUIRED >
<!-- Modifier descriptions -->
<!ELEMENT modifierMap (keyMapSelect+) >
<!ATTLIST modifierMap id ID #REQUIRED >
<!ATTLIST modifierMap defaultIndex NMTOKEN #REQUIRED >
<!ELEMENT keyMapSelect (modifier+) >
<!ATTLIST keyMapSelect mapIndex NMTOKEN #REQUIRED >
<!ELEMENT modifier EMPTY >
<!ATTLIST modifier keys CDATA #REQUIRED >
<!-- Keyboard mapping -->
<!ELEMENT keyMapSet (keyMap+) >
<!ATTLIST keyMapSet id ID #REQUIRED >
<!ELEMENT keyMap (key+) >
<!ATTLIST keyMap index NMTOKEN #REQUIRED >
<!ELEMENT key (action*) >
<!ATTLIST key code NMTOKEN #REQUIRED >
<!ATTLIST key output CDATA #IMPLIED >
<!ATTLIST key action IDREF #IMPLIED >
<!-- Actions (state records) -->
<!ELEMENT actions (action+) >
<!ELEMENT action (when+) >
<!ATTLIST action id ID #IMPLIED >
<!ELEMENT when EMPTY >
<!ATTLIST when state NMTOKEN #REQUIRED >
<!ATTLIST when through NMTOKEN #IMPLIED >
<!ATTLIST when output CDATA #IMPLIED >
<!ATTLIST when multiplier NMTOKEN #IMPLIED >
<!ATTLIST when next NMTOKEN #IMPLIED >
<!-- Terminators -->
<!ELEMENT terminators (when+) >
<!-- Entities for US keyboard layout virtual key codes -->
<!-- Incomplete for now; should this be in an external parameter entity? -->
<!ENTITY keyUSa "0" >
<!ENTITY keyUSs "1" >
<!ENTITY keyUSd "2" >