简体   繁体   中英

Safe keyboard shortcut for activating code completion style functionality in Mac OS X browsers

I'm building some code completion style text expansion functionality for text areas and inputs in a web application. I'm trying to work out a safe keyboard shortcut for invoking the completion proposals for browsers running on Mac OS X.

I've eliminated some potential candidates:

  • Command + Space - activates the Spotlight search field
  • Control + Space - activates the context menu in Firefox
  • Esc - cancels any background XMLHttpRequests in Firefox

That leaves Option + Space . I'm aware that may conflict with tools like Ubiquity , but that's something we don't expect our audience to be using.

Are there any conflicts I may have missed with Option+Space? Or do you have a better idea for a keyboard shortcut, and why?

许多Mac OS X应用程序使用Option + Esc进行代码完成或代码提示。

As I recall, Visual Studio and TextMate both use tab to code-complete. In Visual Studio an intellisense menu pops up as you start typing and tab acts as the selection confirmation.

In TextMate, you start typing part of a command then hit tab to activate said command's associated "bundle". The associated bundle typically generates a code snippet and fills in any dynamic parts of the snippet as you type.

Come to think of it, most command lines work this way as well, auto-completing file names and paths when tab is pressed after typing a few characters.

EDIT: You say tabs are needed for field switching in a web interface, but you may want to try intercepting the keyboard event in the textfield, and check if they're started typing a macro. If they have, auto-complete and swallow the key by returning false; if not, simply let the command bubble through.

某些选项卡快捷方式听起来像是最好和最直观的方法-用户应该习惯于'type-tab-type-tab'工作流程-如果只希望是可选的,可以将其与修饰符结合使用。

I discussed these ideas with our design team. One of them suggested using Control + Enter , which is what we decided to go with. This causes forms that only contain a single input field to automatically submit in Firefox, but we deal with that by preventing the default action caused by the event.

I re-assigned the Spotlight command to Command + Shift + Space . This is easily done via Prefrences.App

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM