views:

670

answers:

5

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
  • Escape - 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?

A: 

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.

Soviut
Unfortunately using Tab doesn't work in a web browser context as it's used to move between fields on a page. There's no way of knowing if the user intended to move to the next field or if they wanted to activate the text completion feature.
Simon Lieschke
Agreed, 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.
Soviut
True. But the problem still exists in an edge case. If the user hits tab when there are no matches you can't tell if they wanted to move to the next field or if they intended to invoke a completion with a code they thought was valid. In the latter case I want to inform them there are no matches.
Simon Lieschke
Tabbing to the next field should be enough of an indication that there was no match.
Chris Upchurch
If there was no match the user will undoubtedly want to continue editing in the original field and not have their cursor moved onto the next field.
Simon Lieschke
A: 

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

sal
I'm working on the basis that most of users will be using the default keyboard shortcut for spotlight.
Simon Lieschke
A: 

Some kind of tab shortcut sounds like the best and most intuitive approach - users should be used to the 'type-tab-type-tab' workflow - maybe combine it with a modifier if it only wants to be optional.

Mark Pim
A: 

A lot of Mac OS X apps use Option+Esc to do code completion or code hints.

mipadi
This requires moving the left hand away from the home position, which we'd like to avoid.
Simon Lieschke
A: 

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.

Simon Lieschke