增加两个Anki快捷键,设定样式和跳转【Front,Back】

在 Anki 输入要背的单词,更方便,脱离鼠标

  1. 首先下载 Customize Keyboard Shortcuts

  2. 在 Tools > Add-ons > Custom Shortcuts 查看文件

找到 config.json 添加

"editor mark selection":"Ctrl+H",
"editor change focus to Back":"Ctrl+1",
"editor change focus to Front":"Ctrl+0"

Ctrl+H 就是设定样式

Ctrl+1 跳转Back输入框

Ctrl+0 跳转Front输入框

  1. 找到 cs_functions.py 添加两个函数
def editor_mark_selection(self):
	self.toggleBold()
	self.toggleUnderline()
	self.onForeground()
	
def change_focus_to(self, num):
	self.web.setFocus()
	self.web.eval("focusField(%d);" % num)

editor_mark_selection 用于设定样式,加粗+加下划线+设置颜色

change_focus_to 用于跳转不用的Field

在 editor_sToF 函数的 sdict 字典中添加

"editor mark selection": (lambda: editor_mark_selection(self),),
"editor change focus to Back": (lambda: change_focus_to(self, 1),),
"editor change focus to Front": (lambda: change_focus_to(self, 0),),
  1. 找到custom_shortcuts.py 添加两个函数
def editor_mark_selection(self):
	self.toggleBold()
	self.toggleUnderline()
	self.onForeground()
	
def change_focus_to(self, num):
	self.web.setFocus()
	self.web.eval("focusField(%d);" % num)

与上面的两个函数一致

在 cs_editor_setupShortcuts 函数的 cuts 数组中添加

(config_scuts["editor mark selection"], lambda: editor_mark_selection(self)),
(config_scuts["editor change focus to Back"], lambda: change_focus_to(self, 1)),
(config_scuts["editor change focus to Front"], lambda: change_focus_to(self, 0))

注意Python的语法错误

  1. 重启 Anki 就可以使用快捷键了,Enjoy Hacking