The kvoptions package gives you the possibility to define key=value style options. It "connects package keyval with LATEX's package and class options" (quote from the manual).
You can then declare options like margin using:
\DeclareStringOption [<init>]{<key>}[<default>]
were <init> is the initial value (also used when the option is not used), <key> stands for the option name and <default> for the default value used when the option is used without an value (foobar instead of foobar=<value>).
If no default value is given the option requires a value, which makes sense for an option like margin for example.
The pgfopts package is an alternative and uses the pgfkeys package, i.e. the key-value engine of PGF/TikZ, which is IMHO more powerful and flexible than keyval or xkeyval.
Please note that keys with spaces are not supported as package or class options because the internal LaTeX macros remove all spaces from the options before the above package receive them.