You're in luck. The StringGadget supports two very handy events, #PB_EventType_Focus and #PB_EventType_LostFocus. So you can have your shortcut active only when the string gadget has the focus and at no other time:
Select Event
Case #PB_Event_Gadget
Select gadget
Case mystring
Select EventType()
Case #PB_EventType_Focus
;AddKeyboardShortcut([..])
Case #PB_EventType_LostFocus
;RemoveKeyboardShortcut([..])
EndSelect
EndSelect
EndSelect
> It's not a real error, but users can suppose, that something wrong
Well it is an error, because single-line StringGadgets can't have the Enter key
used on them because they're not multi-line. That's why they beep like that.