In InputField, how to prevent Shift-Return from generating a new cell?

If you notice Mathematica Documentation Center search field is kind of the same thing. And search window from Ctrl-F too. It uses a similar concept to what I'll show. Important thing to know is that EventHandler can track commands from the Mathematica menu. There is an undocumented option HandleShiftReturn and here is a trick I learned from FW:

DynamicModule[{x = ""}, 
  Column[{
    EventHandler[
      InputField[Dynamic[x], String], 
      {{"MenuCommand", "HandleShiftReturn"} :> {},
       {"MenuCommand", "EvaluateCells"} :> {}} (*edit by Kuba, handles Keypad Enter*)
    ], 
    Dynamic[x]
   }]
]

enter image description here

Return works, but Shift-Return does not.


ExpressionCell[Panel@DynamicModule[{input = ""}, InputField[Dynamic[input], String]]]

Mathematica graphics
Content added:

Mathematica graphics

ShiftReturn pressed:

Mathematica graphics

Learned this here.


This is just adding a Deployed->True to your output cell, and removing the CellEditDuplicate which ruins everything

CellPrint@
  ExpressionCell[
   Panel@DynamicModule[{input = ""}, 
     InputField[Dynamic[input], String]], "Output",  
   CellEditDuplicate -> False, Deployed -> True];

Actually, with CellEditDuplicate->False should be enough. However, keep Deployed in mind if you use other styles, and so Evaluatable->False