It's been a while since I did a keyboard hack, but if IIRC, in order to prevent ghosting you will need to use only choices from a single row or column. Since a joystick cannot be both up and down, nor left and right, simultaneously, up and down can be from a separate row/column, and same for left and right.
You can put your non-gaming keys (for controlling your front-end, choosing games, etc.) on a separate row/column, since these will most likely not be pressed during gameplay. This doesn't apply to coin-up and player keys, since these are often pressed during gameplay.
If you really want to use a keyboard hack, you should look for a matrix with the most pins on a single side. e.g., a 12x12 matrix can support 144 keyboard keys, but only gives 12 non-ghosting keys. A 16x8 matrix can only support 128 keyboard keys, which is less, but can support 16 non-ghosting keys, which is more. It looks like your keyboard has a 20x8 matrix, providing 20 non-ghosting keys. I don't believe I've ever seen a matrix side with this many. What keyboard is this?
Hope this helps.
Mario