Using event->ascii to distinguish between Num Lock states. When Num Lock is off, there is no ascii character associated with the numpad keys. This works with ghost SystemWin32, SystemX11 and should work with SystemCocoa (as it is assigning utf8[0] to ascii). Ghost SystemSDL needs a small patch because of the hardcoded keyboard layout.
This patch adds two options to the Input section of the user preferences. "Ignore Num Lock" is enabled by default, to avoid changing default behaviour. When it is disabled the numpad keys behave like Home, End, Insert, Delete, Page Up, Page Down and Arrow keys (Note: Enter, +, -, *, and / are not affected by this patch.). The second option is "Custom Numpad Keys" which will map the keys to a newly defined set of keys. This allows to avoid having two keys of each.
Example:
With default settings Numpad 7 will always show up as Numpad 7 in the keymap editor. With "Ignore Num Lock" disabled, it will show up as Numpad 7 or Home. With "Custom Numpad Keys" enabled, it will show up as Numpad 7 or Custom 7.
With respect to text editing when Num Lock is off, the numpad keys can not be used to write numbers, independent of all settings.