Prevent a Mac from waking up from keyboard or mouse?

The solution I can offer is to use Sleepwatcher and add the following to your ~/.wakeup script:

#!/bin/bash

WR=`syslog | grep -i "Wake reason =" | tail -1 | awk '{ print $11 }'`

if [[ "$WR" =~ EHC[0-9] ]]; then
    pmset sleepnow
fi

This won't prevent your Mac from waking via keyboard or mouse. It will however sleep the computer immediately after it is woken via keyboard, mouse, or any other USB device.

According to an anonymous user this works for some versions of OS X (e.g. Mavericks):

#!/bin/bash

WR=`syslog | grep -i "Wake reason:" | tail -1 | awk '{ print $11 }'`

if [[ "$WR" =~ EHC[0-9] ]]; then
    pmset sleepnow
fi