Add a special character on keypress not working

Solution 1:

There is no reason within your code or jquery that you would get "ą".

But anyway, why bind to all three events: keypress, keydown and keyup? That will result in multiple characters being added for a single key press.

The following seems to work fine.

$('input').on('keydown', function (event) {
    if (event.altKey && event.key == 'a') {
        event.preventDefault();
        this.value += 'á';
    }
});

console.log('\xE1' === 'á');    // true
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input></input>