Skip to main content
Calcimator

Keyway Design Calculator

Design shaft keyways by calculating shear and compressive stresses in the key. Determine minimum key length and safety factor.

About this calculator

This calculator checks whether a shaft key — the small rectangular bar that locks a gear, pulley, or coupling to a shaft — is strong enough to transmit a given torque without shearing or crushing. It first converts torque into a tangential force at the shaft surface, F = 2T/d, then evaluates that force two ways: shear stress across the key's width-times-length cross-section (τ = F/(wL)), and compressive (bearing) stress against only half the key's height, since a standard key sits half-embedded in the shaft's keyseat and half in the hub's keyway (σ = F/((h/2)L)). Allowable stresses are derived from the key material's yield strength with a safety factor of 2 baked in — shear uses the distortion-energy (von Mises) relation, 0.577 × Sy/SF, while bearing uses Sy/SF directly.

From those allowables the calculator back-solves for the minimum key length needed to survive shear and bearing separately, then reports the larger of the two as the governing minimum length, along with an overall safety factor comparing your actual key length against both failure modes. A result below about 2.0 signals the key should be lengthened, widened, or upgraded to a stronger material (or that you should switch to two keys or a spline). This follows the standard machine-design approach for parallel (square/flat) keys sized per ASME/ANSI B17.1, Keys and Keyseats, the standard that defines square and flat key cross-sections as a function of shaft diameter; it doesn't cover woodruff keys, tapered keys, or fatigue from repeated torque reversals, which need a separate check.

Inputs

in
in·lb
in
in
in
psi

Results

Minimum Key Length

1.11 in

Safety Factor

1.8

Shear Stress5,000 psi
Compressive Stress10,000 psi
Force on Key5,000 lb

Figures current as of 2023. Source: American Society of Mechanical Engineers, ASME/ANSI B17.1-1967 (R2023), Keys and Keyseats

How to Use This Calculator
  1. Enter the Shaft Diameter in inches — ANSI B17.1 standard key sizes are based on shaft diameter.
  2. Enter the Transmitted Torque in in·lb — compute as T = 63,025 × HP / RPM if starting from power.
  3. Enter the Key Width (w) and Key Height (h) in inches — for square keys w = h; use ANSI B17.1 tables for standard sizes.
  4. Enter the Active Key Length (L) — the engaged portion should be at least 1 to 1.5 times the shaft diameter.
  5. Enter the Key Yield Strength in psi: standard 1018 steel key stock ≈ 36,000 psi.
  6. Review the Minimum Key Length required for shear and bearing, the Shear and Compressive Stresses, and the Safety Factor — values below 2.0 warrant a larger key or stronger material.

How the result changes with Shaft Diameter

Shaft DiameterMinimum Key LengthSafety Factor
12.22 in0.9
1.51.48 in1.35
30.74 in2.7
50.44 in4.5

What each input means

Shaft Diameter
Diameter of the shaft at the keyway location. Key size is typically standardized based on shaft diameter.
Transmitted Torque
Torque transmitted through the keyed connection. T = 63,025 × HP / RPM.
Key Width (w)
Width of the square or rectangular key. Standard: 1/4 shaft diameter (ANSI B17.1).
Key Height (h)
Height (thickness) of the key. Square keys have h = w; flat keys have h < w.
Key Length (L)
Active engaged length of the key. Should be at least 1× to 1.5× the shaft diameter.
Key Yield Strength
Yield strength of the key material. Standard key stock (1018 steel) ≈ 36,000 psi.

How this is calculated

Worked example, using the default values

  1. Identify Input Parameters
    4 parameters
    Shaft Diameter = 2, Transmitted Torque = 5000, Key Width (w) = 0.5, Key Height (h) = 0.5 = 6 input(s) provided
  2. Calculate Minimum Key Length
    Minimum Key Length
    1.111 = 1.111
  3. Calculate Safety Factor
    Safety Factor
    1.8 = 1.8
  4. Calculate Shear Stress
    Shear Stress
    5000 = 5000
  5. Calculate Compressive Stress
    Compressive Stress
    10000 = 10000

Figures and sources

Engine last updated . Checked against 2 independently-derived tests — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.

Frequently Asked Questions

Why does the compressive stress calculation only use half the key's height?

A standard parallel key sits in matching keyseats — half its height recessed into the shaft, half into the hub. So the bearing contact area on each side is only (h/2) × L, not the full key height times length, which is why compressive stress is calculated as σ = F/((h/2)L) rather than F/(hL).

Can bearing (compressive) failure govern even when shear looks fine?

Yes. Shear stress uses the full width-times-length area (w × L) while bearing stress uses only half the height times length ((h/2) × L), so if your key is wide but short in height relative to width, the bearing area can be smaller than the shear area and bearing stress can exceed shear stress even though the same force F drives both. The calculator computes minimum length for each failure mode independently and reports the larger requirement so neither is overlooked.

Why does the calculator compute two separate minimum key lengths instead of one?

Shear and bearing are independent failure modes with different allowable stresses (0.577 × Sy/SF for shear, Sy/SF for bearing) and different governing areas, so a key long enough to survive shear isn't automatically long enough to survive bearing, or vice versa. The calculator solves each minimum length separately from the respective allowable and reports the larger of the two as the true governing minimum.

Does this check account for stress concentration at the keyway notch in the shaft itself?

No — this analysis only evaluates the key's own shear and bearing strength, not the stress concentration created by the keyway notch cut into the shaft. That notch effect needs a separate fatigue check (typically using Peterson's stress-concentration charts) and matters most under reversing or cyclic torque, which this calculator doesn't model.

The questions that sit next to this one — chosen by subject, including calculators filed under a different category.

More in Engineering.