global key detect and small fixes