⌨️

Keyhac で JIS 配列を US 配列に置換

2024/04/29に公開

なるべく HHKBに近づけたくて、E/J は Escape にした。
また、その玉突きで以下のようにした。

  • Backspace の左隣の Yen は '`' に(Shift-Yen は '~' に)。
  • Enter の左隣の CloseBracket(]) は '' に(Shift-CloseBracket は '|'に)。
import sys
import os
import datetime

import pyauto
from keyhac import *


def configure(keymap):

    # --------------------------------------------------------------------
    # Text editer setting for editting config.py file

    # Setting with program file path (Simple usage)
    if 1:
        keymap.editor = "notepad.exe"

    # Setting with callable object (Advanced usage)
    if 0:
        def editor(path):
            shellExecute( None, "notepad.exe", '"%s"'% path, "" )
        keymap.editor = editor

    # --------------------------------------------------------------------
    # Customizing the display

    # Font
    keymap.setFont( "MS Gothic", 12 )

    # Theme
    keymap.setTheme("black")

    # --------------------------------------------------------------------

    # Simple key replacement
    #keymap.replaceKey( "LWin", 29 )
    #keymap.replaceKey( "RWin", 28 )
    #keymap.replaceKey( "RAlt", "RWin" )
 

    # --------------------------------------------------------------------
    # 以下、US 配列化設定
    kmg = keymap.defineWindowKeymap()
 
    # S-2 => @
    kmg[ "Shift-2" ] = "Atmark"
    
    # S-6 => ^
    kmg[ "Shift-6" ] = "Caret"

    # S-7 => &
    kmg[ "Shift-7" ] = "Shift-6"

    # S-8 => *
    kmg[ "Shift-8" ] = "Shift-Colon"

    # S-9 => (
    kmg[ "Shift-9" ] = "Shift-8"

    #@ S-0 => )
    kmg[ "Shift-0" ] = "Shift-9" 

    # S-- => _
    kmg[ "Shift-Minus" ] = "Shift-BackSlash"

    # ^ => =
    kmg[ "Caret" ] = "Shift-Minus"

    # S-^ => +
    kmg[ "Shift-Caret" ] = "Shift-Semicolon"

    # \ => `
    kmg[ "Yen" ] = "Shift-Atmark"

    # S-\ => ~
    kmg[ "Shift-Yen" ] = "Shift-Caret"


    # @ => [
    kmg[ "Atmark" ] = "OpenBracket"
    # S-@ => {
    kmg[ "Shift-Atmark" ] = "Shift-OpenBracket"

    # [ => ]
    # S-[ => }
    kmg[ "OpenBracket" ] = "CloseBracket"
    kmg[ "Shift-OpenBracket" ] = "Shift-CloseBracket"


    # S-; => :
    kmg[ "Shift-Semicolon"  ] = "Colon"

    # : => '
    kmg[ "Colon" ] = "Shift-7"

    # S-: => "
    kmg[ "Shift-Colon" ] = "Shift-2"

    # ] => \
    # Shift-] => |
    kmg[ "CloseBracket" ] = "Yen"
    kmg[ "Shift-CloseBracket" ] = "Shift-Yen"

    ## 半角/全角 => Escape
    kmg[ "(243)" ] = "Escape"
    kmg[ "(244)" ] = "Escape"

Discussion