Smooth out the carpet over the doorway and feel it with your hands to locate the area where it meets the other type of flooring. Place a straightedge on top of the carpet and cut along the line, using a utility knife to trim off the excess.
Pull the edge of the carpet back 1 to 2 feet so you can see the underlying subfloor, which may be concrete or plywood. Vacuum the subfloor to remove all dirt and grit.
Measure the width of the doorway, using a tape measure, and then cut a carpet tack strip to the same width, using tin snips.
Insert a tube of heavy-duty construction adhesive into a caulking gun. Snip the last 1/2 inch off the tube nozzle, using scissors. Apply a bead of adhesive along the width of the door. Position the adhesive as close to the edge of the other flooring as possible.
Turn the tack strip so the small tacks face up, and press it into the adhesive. Hammer in the nails on top of the strip so they extend into the subfloor.
Position a carpet kicker tool 3 inches away from the end of the carpet in the doorway. The metal spiked head should face the doorway, and the rubber pad should be near your knee.
Press forward on the knee portion of the tool to stretch the carpet, and use a putty knife to tuck the edge of the carpet into the tack strip down in the floor. Repeat the process along the entire doorway until no portion of the carpet edge remains visible.
Hit the finished edge of the carpet firmly with a hammer to bend the tacks over and prevent injury when walking on them.