通过键盘打开/关闭鼠标键

通过键盘打开/关闭鼠标键

我已在通用访问菜单和许多帖子以及此文档页面中打开鼠标键:

https://help.ubuntu.com/11.10/ubuntu-help/mouse-mousekeys.html

提到 NUMLOCK 或 SHIFT+NUMLOCK 可以打开或关闭此功能。这两种方法对我来说都不起作用。我似乎只能使用 Universal Access 菜单来关闭此功能,如果我只想关闭它来输入几个数字,那就太烦人了。

我在 Windows 上使用鼠标键,效果很好。

我正在运行 Ubuntu 11.10,我的键盘是 MS Ergonomic 4000。

我想知道是否有其他配置设置阻碍了这一过程?

答案1

我也遇到了同样的问题。我也(仍然)在使用 Ubuntu 11.10。

在日常工作中我主要使用鼠标键是因为我喜欢使用数字 5 键来按下鼠标按键。

然后我发现在 Unity 中你可以进行非常好的窗口平铺(ctrl-alt-num4 将窗口发送到屏幕左侧,ctrl-alt-num6 发送到右侧,ctrl-alt-9 发送到右上角,等等)。

因此,为了平铺窗口,我想暂时禁用鼠标键。

我在这里找到了答案:http://ubuntuforums.org/showpost.php?p=11776864&postcount=4

我将脚本保存为 ubuntu-toggle-mousekeys,需要时输入:

bash ubuntu-切换鼠标键

...在我的终端。

这是我稍微修改过的脚本 - 我只是添加了一些评论:

#!/bin/bash

# http://ubuntuforums.org/showthread.php?t=1942984

# I needed this when I connected a big monitor to my ubuntu laptop.
# Unity has nice window tiling shortcuts that need the number keypad to work.
# ctrl-alt-num4 sends a window left, ctrl-alt-num6 sends a window right, etc.

STATUS=$(gsettings get org.gnome.desktop.a11y.keyboard mousekeys-enable) #Are mousekeys on (true or false)

if [ "$STATUS" == "true" ]
then
  gsettings set org.gnome.desktop.a11y.keyboard mousekeys-enable false 

  notify-send -i  "/usr/share/icons/gnome/48x48/devices/keyboard.png" "                    Mousekeys OFF"
  echo "Mousekeys are OFF - use ctrl-alt-num4 to send window left, ctrl-alt-num6 to send window right"

else
  gsettings set org.gnome.desktop.a11y.keyboard mousekeys-enable true

  notify-send -i  "/usr/share/icons/gnome/48x48/devices/keyboard.png" "                    Mousekeys ON"
  echo "Mousekeys are ON"
fi

答案2

bash 代码不起作用,请尝试这个:

#!/usr/bin/env ruby

# http://ubuntuforums.org/showthread.php?t=1942984

# I needed this when I connected a big monitor to my ubuntu laptop.
# Unity has nice window tiling shortcuts that need the number keypad to work.
# ctrl-alt-num4 sends a window left, ctrl-alt-num6 sends a window right, etc.

#Are mousekeys on (true or false)
r = `gsettings get org.gnome.desktop.a11y.keyboard mousekeys-enable`

p r

if r =~ /true/i
  `gsettings set org.gnome.desktop.a11y.keyboard mousekeys-enable false `
  `notify-send -i  "/usr/share/icons/gnome/48x48/devices/keyboard.png" "Mousekeys OFF" `
  puts "Mousekeys are OFF - use ctrl-alt-num4 to send window left, ctrl-alt-num6 to send window right"

else
  `gsettings set org.gnome.desktop.a11y.keyboard mousekeys-enable true `

  `notify-send -i  "/usr/share/icons/gnome/48x48/devices/keyboard.png" "Mousekeys ON" `
  p "Mousekeys are ON"
end

相关内容