Guide · Milling

How to Machine a Keyway in a Shaft and a Hub

Keyway milling, broaching and shaping: how to hold the shaft, find the centre, reach the width tolerance, measure the depth, and make internal keyways on a CNC machine.

By cnccode · Updated
On this page
  1. Size and tolerance
  2. Keyway in the shaft
  3. Keyway in the hub
  4. Measuring
  5. More guides
  6. Frequently asked questions

Size and tolerance

Take the key from the shaft diameter. A 25 mm shaft needs an 8 × 7 key with 4 mm depth in the shaft. The keyway calculator shows all values and checks the strength. The slot width is usually P9 (tight) or N9 (normal). For 8 mm that means: P9 = 7.949 to 7.985 mm and N9 = 7.964 to 8.000 mm.

Keyway in the shaft

  1. Hold the shaft in V-blocks or in a vise with a V-jaw, and check that it is parallel to X.
  2. Find the centre with an edge finder on both sides, or with a probe.
  3. Touch off Z on the highest point of the shaft. The edge of the slot is lower. For a 25 mm shaft and an 8 mm slot the difference is 0.66 mm.
  4. Rough with a cutter that is one size smaller, for example 7 mm for an 8 mm slot.
  5. Finish each wall separately. An 8 mm cutter in one pass nearly always makes a slot that is too wide, because it is pushed sideways and has runout.

Keyway in the hub

  • Broaching with a push broach and a guide bushing is fast and accurate for through holes.
  • Shaping on the lathe: lock the spindle and use a tool in the turret like a slotting machine. Take 0.03 to 0.08 mm per stroke and retract before moving back. This loads the turret and the spindle brake, so ask the machine builder about the limits.
  • Wire EDM for hardened parts.
G-code: one stroke of a lathe keyway (repeat with a smaller depth step)
G98
G00 X24.5 Z3.
X25.1
G01 Z-30. F2000.
G00 X24.5
Z3.

Measuring

In the shaft measure from the slot bottom to the opposite side: d − t1. In the hub measure from the slot bottom to the opposite bore wall: d + t2. Both are simple with a caliper or an internal gauge and avoid the missing top of the circle.

Frequently asked questions

What is the difference between form A and form B keys?
Form A has round ends and sits in a slot made with an end mill. Form B has square ends and is used in slots made with a disc cutter.
Why is my keyway wider than the cutter?
Runout and deflection. Use a smaller cutter and finish both walls in separate passes.
Was this page helpful?