终端可以检测到<Shift-Enter>吗?或&lt;Control-Enter&gt;? [英] Can terminals detect &lt;Shift-Enter&gt; or &lt;Control-Enter&gt;?

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

问题描述

终端是否可以检测⇧ 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↵!

推荐答案

当按下 时,某些终端会发送 .这相当于发送.

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

要了解您的终端如何使用 ,转到您的终端,输入 (类似于 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 给出了 序列.

Looking at man ascii indicates that ^M gives the <CR> sequence.

答案是它取决于终端,并且有一种简单的方法可以检查.

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

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

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