终端能否检测到<Shift-Enter>还是<Control-Enter>? [英] Can terminals detect <Shift-Enter> or <Control-Enter>?

查看:20
本文介绍了终端能否检测到<Shift-Enter>还是<Control-Enter>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

终端是否可以检测到 ⇧ Shift+Enter↵Ctrl+Enter↵ 按键?

Is it possible for the terminal to detect ⇧ Shift+Enter↵ or Ctrl+Enter↵ keypresses?

我正在尝试将 vim 配置为使用这些序列进行键映射,虽然它们在 gvim 中工作正常,但它们似乎在任何终端控制台中都不起作用.

I am trying to configure vim to do key mappings that use these sequences, and while they work fine in gvim, they don't seem to work in any terminal console.

奇怪的是,虽然在vim中没有检测到Ctrl+Enter↵,但是将Enter↵映射到Esc 正确映射,但随后按 Ctrl+Enter↵ 的行为类似于 Enter↵

The curious thing is that although Ctrl+Enter↵ is not detected in vim, mapping Enter↵ to Esc maps properly, but then pressing Ctrl+Enter↵ behaves like Enter↵!

推荐答案

当按下<C-Enter>时,某些终端会发送.这相当于发送 <C-J>.

Some terminals send <NL> when <C-Enter> is pressed. This is equivalent to sending <C-J>.

了解终端对 <Shift-Enter><Ctrl-Enter><Enter> 的作用,进入你的终端,输入 <Ctrl-V>(类似于 sykora 对 vim 的建议),然后输入你感兴趣的序列.

To find out what your terminal does with <Shift-Enter>, <Ctrl-Enter> and <Enter>, go to your terminal, type <Ctrl-V> (similar to sykora's suggestion for vim), and type in the sequence you're interested in.

使用 gnome-terminal,我得到以下信息:

Using gnome-terminal, I get the following:

  <Enter> : ^M
<S-Enter> : ^M
<C-Enter> : <NL>

查看man ascii表示^M给出<CR>序列.

答案是取决于终端,有一个简单的方法来检查.

The answer is that it depends on the terminal, and there's an easy way to check.

这篇关于终端能否检测到&lt;Shift-Enter&gt;还是&lt;Control-Enter&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆