Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

How to Make the enter key act like the tab key

I am writing a simple entry form but the users are used to hitting the enter key to move to the next field.

Wednesday, October 1, 2003

What sort of application is this?  Windows Forms?  Browser-based/ASP.NET?

Thursday, October 2, 2003

This app is a WinForm.  I am rewriting a terminal dos app for a client. 

Thursday, October 2, 2003

I'd be a fan of reeducating users in a case like this, as using TAB to move between form fields is awfully standard.

If you can't do that, you can always trap the KeyUp event (or something similar) for each textbox and reset the focus.  This is going to be a lot of annoying snippets of code for very little benefit, though.

Thursday, October 2, 2003

You can hook message loop .
Application Class and than change Enter to Tab
Use "Application.AddMessageFilter" Method
to cahnge for whole app,
or you can use
Form.KeyPreview property and
KeyPress, KeyDown, and KeyUp event to handle it

Filipovic slobodan
Friday, October 10, 2003

Unless the users are completely computer illerate, and the only time they ever touch a computer is to use this app, they are much better served being re-trained to the standard way of doing things.

Besides, the app won't always be used by the current crop of users. New users will expect tab and enter to do specific things, and you'll have overriden it for no better reason than "it used to be the way it worked before". Those users will be better served, too, by sticking with the standard.

Brad Wilson (
Saturday, October 11, 2003

Users would like it. For experiment try to enter 20 numbers
with decimal places, like for values, but imagine that you are
holding an invoice or any kind of list of these numbers in
your left hand. Using numeric keypad is so much easier.

So real answer would be to have Return key on keypad
act like tab, and Enter key (below the backspace) as
real Enter key for buttons.


Igor Delovski
Tuesday, October 14, 2003

an interesting point. that's also the exact opposite of the macintosh, oddly enough. on the mac, return (above shift key) = CR/newline, enter (typically on the numeric keypad) = accept values in dialog box. well at least before OSX, who knows what they did there.

on windows, control-enter (either one) = accept values in dialog box. usually.

Tuesday, October 14, 2003

Add this:

using System;
using System.Windows.Forms;
public class TestMessageFilter : IMessageFilter {
    public bool PreFilterMessage(ref Message m) {
      if (m.Msg == 0x0102 ) {
          int c = m.WParam.ToInt32();
          if (c == (int) Keys.Enter)
                  return true;
      return false;

and this :

public static void Main(string[] args)
Application.AddMessageFilter( new TestMessageFilter());
Application.Run(new MainForm());

Filipovic Slobodan
Monday, November 3, 2003

Why don't they just put a Tab key on the numeric keypad?  Those "plus" and "enter" keys could be made a little smaller to make room.

Dana Hoffman
Thursday, November 13, 2003

Why are you typing on "qwerty" or  "azerty" keyboards?
They put enter key on numeric keypad becouse of Calc.exe.
Most common operation are + and = and that is the reason why those buttons are bigger.

Filipovic Slobodan
Friday, November 14, 2003

*  Recent Topics

*  Fog Creek Home