From your comments, it is now clear that you've defined a macro that includes using the key $
. If you do this, you can't then bind the macro to the $
, because that makes it recursive - every time you get to the $
in your macro, you are in effect calling the macro again.
You could, however, define the actions you want performed as an elisp function, which you could then bind to $
. If we knew what you were actually doing with your macro we might be able to show you how.
EDIT: how about this:
(global-set-key (kbd "$") #'(lambda () (interactive) (insert " $")))
That should work, but lambdas can be a bit confusing. A little clearer for elisp beginners might be:
(defun my-dollars ()
"Insert a dollar sign with a space in front."
(interactive)
(insert " $"))
(global-set-key (kbd "$") 'my-dollars)